/* * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.datamodel; /** * An enumeration of the kinds of mapping (from nucleotide or peptide, to * nucleotide or peptide), and the corresponding word lengths. This is based on, * but extends (and renames) the values used by Exonerate. * * @see https://www.ebi.ac.uk/about/vertebrate-genomics/software/exonerate-manual */ public enum MappingType { GenomeToCdna(1, 1), CdnaToGenome(1, 1), GenomeToCds(1, 1), CdsToGenome(1, 1), CdnaToCds(1, 1), CdsToCdna(1, 1), GenomeToPeptide(3, 1), PeptideToGenome(1, 3), CdnaToPeptide(3, 1), PeptideToCdna(1, 3), CdsToPeptide(3, 1), PeptideToCds(1, 3); private int fromRatio; private int toRatio; private MappingType(int fromSize, int toSize) { fromRatio = fromSize; toRatio = toSize; } /** * Answers the number of positions each 'word' maps from (e.g. 3 when mapping * from codons in nucleotide to peptide residues) * * @return */ public int getFromRatio() { return fromRatio; } /** * Answers the number of positions each 'word' maps to (e.g. 3 when mapping * from peptide residues to codons in nucleotide) * * @return */ public int getToRatio() { return toRatio; } /** * Answers true if the mapping is from nucleotide to peptide, else false * * @param type * @return */ public static boolean isDnaToPeptide(MappingType type) { return type != null && type.getFromRatio() == 3 && type.getToRatio() == 1; } /** * Answers true if the mapping is from peptide to nucleotide, else false * * @param type * @return */ public static boolean isPeptideToDna(MappingType type) { return type != null && type.getFromRatio() == 1 && type.getToRatio() == 3; } }