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
46 public static final String UNIPROT = "UNIPROT";
47 public static final String UP_NAME = "UNIPROT_NAME".toUpperCase(Locale.ROOT);
49 * Uniprot Knowledgebase/TrEMBL as served from EMBL protein products.
51 public static final String UNIPROTKB = "UniProtKB/TrEMBL".toUpperCase(Locale.ROOT);
53 public static final String ENSEMBL = "ENSEMBL";
54 public static final String ENSEMBLGENOMES = "ENSEMBLGENOMES";
56 public static final String EMBL = "EMBL";
57 public static final String EMBLCDS = "EMBLCDS";
58 public static final String EMBLCDSProduct = "EMBLCDSProtein".toUpperCase(Locale.ROOT);
60 public static final String PDB = "PDB";
61 public static final String PFAM = "PFAM";
62 public static final String RFAM = "RFAM";
63 public static final String GENEDB = "GeneDB".toUpperCase(Locale.ROOT);
65 public static final String PDB_CANONICAL_NAME = PDB;
68 public static final String[] allSources = new String[] {
71 ENSEMBL, ENSEMBLGENOMES,
72 EMBL, EMBLCDS, EMBLCDSProduct,
73 PDB, PFAM, RFAM, GENEDB
76 public static final int UNIPROT_MASK = 1<<0;
77 public static final int UP_NAME_MASK = 1<<1;
78 public static final int UNIPROT_KB_MASK = 1<<2;
79 public static final int ENSEMBL_MASK = 1<<3;
80 public static final int ENSEMBL_GENOMES_MASK = 1<<4;
81 public static final int EMBL_MASK = 1<<5;
82 public static final int EMBL_CDS_MASK = 1<<6;
83 public static final int EMBL_CDS_PRODUCT_MASK = 1<<7;
84 public static final int PDB_MASK = 1<<8;
85 public static final int PFAM_MASK = 1<<9;
86 public static final int RFAM_MASK = 1<<10;
87 public static final int GENE_DB_MASK = 1<<11;
89 public static final int MASK_COUNT = 12;
91 public static final int ALL_MASKS = (1 << MASK_COUNT) - 1;
93 public static int getSourceKey(String name) {
94 for (int i = 0; i < MASK_COUNT; i++) {
95 if (name.equals(allSources[i]))
103 public static final int PRIMARY_MASK = UNIPROT_MASK | ENSEMBL_MASK;
106 * List of databases whose sequences might have coding regions annotated
108 public static final String[] DNACODINGDBS = {
109 ENSEMBL, ENSEMBLGENOMES,
110 EMBL, EMBLCDS, GENEDB
113 public static final int DNA_CODING_MASK =
114 ENSEMBL_MASK | ENSEMBL_GENOMES_MASK
115 | EMBL_MASK | EMBL_CDS_MASK | GENE_DB_MASK;
119 public static final String[] CODINGDBS = { EMBLCDS, GENEDB, ENSEMBL };
121 public static final int CODING_MASK = EMBL_CDS_MASK | GENE_DB_MASK | ENSEMBL_MASK;
125 public static final String[] PROTEINDBS = {
127 ENSEMBL, EMBLCDSProduct }; // Ensembl ENSP* entries are protein
129 public static final int PROTEIN_MASK =
130 UNIPROT_MASK | UNIPROT_KB_MASK
131 | ENSEMBL_MASK | EMBL_CDS_PRODUCT_MASK ;
134 // for SequenceAnnotationReport only
136 // public static final String[][] PRIMARY_SOURCES = new String[][] {
137 // CODINGDBS, DNACODINGDBS, PROTEINDBS };
139 public static final int PRIMARY_SOURCES_MASK = CODING_MASK | DNA_CODING_MASK | PROTEIN_MASK;
141 public static boolean isPrimarySource(String source)
143 return ((PRIMARY_SOURCES_MASK & getSourceKey(source)) != 0);
146 public static boolean isPrimaryCandidate(String ucversion) {
147 // tricky - this test really needs to search the sequence's set of dbrefs to
148 // see if there is a primary reference that derived this reference.
149 for (int i = allSources.length; --i >= 0;)
151 if (ucversion.startsWith(allSources[i])) // BH 2019.01.25 .toUpperCase(Locale.ROOT) unnecessary here for allSources
153 // by convention, many secondary references inherit the primary
155 // source string as a prefix for any version information from the
156 // secondary reference.