2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
24 * BH 2018 SwingJS note: If additional final static Strings are added to this
25 * file, they should be added to public static final String[] allTypes.
27 * Defines internal constants for unambiguous annotation of DbRefEntry source
28 * strings and describing the data retrieved from external database sources (see
29 * jalview.ws.DbSourcProxy) <br/>
30 * TODO: replace with ontology to allow recognition of particular attributes
31 * (e.g. protein coding, alignment (ortholog db, paralog db, domain db),
32 * genomic, transcriptomic, 3D structure providing (PDB, MODBASE, etc) ..).
39 import java.util.Locale;
41 public class DBRefSource
44 public static final String UNIPROT = "UNIPROT";
46 public static final String UP_NAME = "UNIPROT_NAME"
47 .toUpperCase(Locale.ROOT);
50 * Uniprot Knowledgebase/TrEMBL as served from EMBL protein products.
52 public static final String UNIPROTKB = "UniProtKB/TrEMBL"
53 .toUpperCase(Locale.ROOT);
55 public static final String ENSEMBL = "ENSEMBL";
57 public static final String ENSEMBLGENOMES = "ENSEMBLGENOMES";
59 public static final String EMBL = "EMBL";
61 public static final String EMBLCDS = "EMBLCDS";
63 public static final String EMBLCDSProduct = "EMBLCDSProtein"
64 .toUpperCase(Locale.ROOT);
66 public static final String PDB = "PDB";
68 public static final String PFAM = "PFAM";
70 public static final String RFAM = "RFAM";
72 public static final String GENEDB = "GeneDB".toUpperCase(Locale.ROOT);
74 public static final String PDB_CANONICAL_NAME = PDB;
76 public static final String[] allSources = new String[] { UNIPROT, UP_NAME,
77 UNIPROTKB, ENSEMBL, ENSEMBLGENOMES, EMBL, EMBLCDS, EMBLCDSProduct,
78 PDB, PFAM, RFAM, GENEDB };
80 public static final int UNIPROT_MASK = 1 << 0;
82 public static final int UP_NAME_MASK = 1 << 1;
84 public static final int UNIPROT_KB_MASK = 1 << 2;
86 public static final int ENSEMBL_MASK = 1 << 3;
88 public static final int ENSEMBL_GENOMES_MASK = 1 << 4;
90 public static final int EMBL_MASK = 1 << 5;
92 public static final int EMBL_CDS_MASK = 1 << 6;
94 public static final int EMBL_CDS_PRODUCT_MASK = 1 << 7;
96 public static final int PDB_MASK = 1 << 8;
98 public static final int PFAM_MASK = 1 << 9;
100 public static final int RFAM_MASK = 1 << 10;
102 public static final int GENE_DB_MASK = 1 << 11;
104 public static final int MASK_COUNT = 12;
106 public static final int ALL_MASKS = (1 << MASK_COUNT) - 1;
108 public static int getSourceKey(String name)
110 for (int i = 0; i < MASK_COUNT; i++)
112 if (name.equals(allSources[i]))
120 public static final int PRIMARY_MASK = UNIPROT_MASK | ENSEMBL_MASK;
123 * List of databases whose sequences might have coding regions annotated
125 public static final String[] DNACODINGDBS = { ENSEMBL, ENSEMBLGENOMES,
126 EMBL, EMBLCDS, GENEDB };
128 public static final int DNA_CODING_MASK = ENSEMBL_MASK
129 | ENSEMBL_GENOMES_MASK | EMBL_MASK | EMBL_CDS_MASK | GENE_DB_MASK;
131 public static final String[] CODINGDBS = { EMBLCDS, GENEDB, ENSEMBL };
133 public static final int CODING_MASK = EMBL_CDS_MASK | GENE_DB_MASK
136 public static final String[] PROTEINDBS = { UNIPROT, UNIPROTKB, ENSEMBL,
137 EMBLCDSProduct }; // Ensembl ENSP* entries are protein
139 public static final int PROTEIN_MASK = UNIPROT_MASK | UNIPROT_KB_MASK
140 | ENSEMBL_MASK | EMBL_CDS_PRODUCT_MASK;
142 // for SequenceAnnotationReport only
144 // public static final String[][] PRIMARY_SOURCES = new String[][] {
145 // CODINGDBS, DNACODINGDBS, PROTEINDBS };
147 public static final int PRIMARY_SOURCES_MASK = CODING_MASK
148 | DNA_CODING_MASK | PROTEIN_MASK;
150 public static boolean isPrimarySource(String source)
152 return ((PRIMARY_SOURCES_MASK & getSourceKey(source)) != 0);
155 public static boolean isPrimaryCandidate(String ucversion)
157 // tricky - this test really needs to search the sequence's set of dbrefs to
158 // see if there is a primary reference that derived this reference.
159 for (int i = allSources.length; --i >= 0;)
161 if (ucversion.startsWith(allSources[i])) // BH 2019.01.25
162 // .toUpperCase(Locale.ROOT)
163 // unnecessary here for
166 // by convention, many secondary references inherit the primary
168 // source string as a prefix for any version information from the
169 // secondary reference.