/*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)\r
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- * \r
- * This program is free software; you can redistribute it and/or\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle\r
+ *\r
+ * This file is part of Jalview.\r
+ *\r
+ * Jalview is free software: you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * \r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
+ *\r
+ * Jalview is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty\r
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
+ * PURPOSE. See the GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
package jalview.analysis;\r
\r
import java.util.Enumeration;\r
+import java.util.List;\r
import java.util.Vector;\r
import java.util.Hashtable;\r
\r
/**\r
* Functions for cross-referencing sequence databases. user must first specify\r
* if cross-referencing from protein or dna (set dna==true)\r
- * \r
+ *\r
* @author JimP\r
- * \r
+ *\r
*/\r
public class CrossRef\r
{\r
/**\r
* get the DNA or protein references for a protein or dna sequence\r
- * \r
+ *\r
* @param dna\r
* @param rfs\r
* @return\r
public static Hashtable classifyDbRefs(DBRefEntry[] rfs)\r
{\r
Hashtable classes = new Hashtable();\r
- classes.put(DBRefSource.PROTEINDBS, jalview.util.DBRefUtils.selectRefs(\r
- rfs, DBRefSource.PROTEINDBS));\r
+ classes.put(DBRefSource.PROTEINDBS,\r
+ jalview.util.DBRefUtils.selectRefs(rfs, DBRefSource.PROTEINDBS));\r
classes.put(DBRefSource.DNACODINGDBS, jalview.util.DBRefUtils\r
.selectRefs(rfs, DBRefSource.DNACODINGDBS));\r
- classes.put(DBRefSource.DOMAINDBS, jalview.util.DBRefUtils.selectRefs(\r
- rfs, DBRefSource.DOMAINDBS));\r
+ classes.put(DBRefSource.DOMAINDBS,\r
+ jalview.util.DBRefUtils.selectRefs(rfs, DBRefSource.DOMAINDBS));\r
// classes.put(OTHER, )\r
return classes;\r
}\r
\r
/**\r
* @param dna\r
- * true if seqs are DNA seqs\r
+ * true if seqs are DNA seqs\r
* @param seqs\r
* @return a list of sequence database cross reference source types\r
*/\r
/**\r
* Indirect references are references from other sequences from the dataset to\r
* any of the direct DBRefEntrys on the given sequences.\r
- * \r
+ *\r
* @param dna\r
- * true if seqs are DNA seqs\r
+ * true if seqs are DNA seqs\r
* @param seqs\r
* @return a list of sequence database cross reference source types\r
*/\r
}\r
\r
/**\r
- * \r
+ *\r
* @param dna\r
* @param seqs\r
* @return\r
}\r
\r
/**\r
- * \r
+ *\r
* @param seqs\r
* @param dna\r
* @param source\r
* @param dataset\r
- * alignment to search for product sequences.\r
+ * alignment to search for product sequences.\r
* @return products (as dataset sequences)\r
*/\r
public static Alignment findXrefSequences(SequenceI[] seqs, boolean dna,\r
* find references to lrfs in the cross-reference set of each sequence in\r
* dataset (that is not equal to sequenceI) Identifies matching DBRefEntry\r
* based on source and accession string only - Map and Version are nulled.\r
- * \r
+ *\r
* @param sequenceI\r
* @param lrfs\r
* @param dataset\r
/**\r
* search a given sequence dataset for references matching cross-references to\r
* the given sequence\r
- * \r
+ *\r
* @param sequenceI\r
* @param xrf\r
* @param dataset\r
* @param rseqs\r
- * set of unique sequences\r
+ * set of unique sequences\r
* @param cf\r
* @return true if one or more unique sequences were found and added\r
*/\r
* TODO: generalise to different protein classifications Search dataset for\r
* DBRefEntrys matching the given one (xrf) and add the associated sequence to\r
* rseq.\r
- * \r
+ *\r
* @param sequenceI\r
* @param xrf\r
* @param dataset\r
* @param rseqs\r
- * @param direct -\r
- * search all references or only subset\r
+ * @param direct\r
+ * - search all references or only subset\r
* @param dna\r
- * search dna or protein xrefs (if direct=false)\r
+ * search dna or protein xrefs (if direct=false)\r
* @return true if relationship found and sequence added.\r
*/\r
public static boolean searchDataset(SequenceI sequenceI, DBRefEntry xrf,\r
System.err.println("Empty dataset sequence set - NO VECTOR");\r
return false;\r
}\r
- Enumeration e = dataset.getSequences().elements();\r
- while (e.hasMoreElements())\r
+ List<SequenceI> ds;\r
+ synchronized (ds=dataset.getSequences())\r
{\r
- SequenceI nxt = (SequenceI) e.nextElement();\r
+ for (SequenceI nxt:ds)\r
if (nxt != null)\r
{\r
if (nxt.getDatasetSequence() != null)\r
DBRefEntry[] poss = nxt.getDBRef(), cands = null;\r
if (direct)\r
{\r
- cands = jalview.util.DBRefUtils.searchRefs(poss , xrf);\r
+ cands = jalview.util.DBRefUtils.searchRefs(poss, xrf);\r
}\r
else\r
{\r
- poss = CrossRef\r
- .findXDbRefs(dna, poss); // \r
+ poss = CrossRef.findXDbRefs(dna, poss); //\r
cands = jalview.util.DBRefUtils.searchRefs(poss, xrf);\r
}\r
if (cands != null)\r
/**\r
* precalculate different products that can be found for seqs in dataset and\r
* return them.\r
- * \r
+ *\r
* @param dna\r
* @param seqs\r
* @param dataset\r
- * @param fake -\r
- * don't actually build lists - just get types\r
+ * @param fake\r
+ * - don't actually build lists - just get types\r
* @return public static Object[] buildXProductsList(boolean dna, SequenceI[]\r
* seqs, AlignmentI dataset, boolean fake) { String types[] =\r
* jalview.analysis.CrossRef.findSequenceXrefTypes( dna, seqs,\r
* System.out.println("Type: " + types[t]); SequenceI[] prod =\r
* jalview.analysis.CrossRef.findXrefSequences(seqs, dna, types[t]);\r
* System.out.println("Found " + ((prod == null) ? "no" : "" +\r
- * prod.length) + " products"); if (prod!=null) { for (int p=0; p<prod.length;\r
- * p++) { System.out.println("Prod "+p+":\r
+ * prod.length) + " products"); if (prod!=null) { for (int p=0;\r
+ * p<prod.length; p++) { System.out.println("Prod "+p+":\r
* "+prod[p].getDisplayId(true)); } } } } else {\r
* System.out.println("Trying getProducts for\r
* "+al.getSequenceAt(0).getDisplayId(true));\r
- * System.out.println("Search DS Xref for: "+(dna ? "dna" : "prot")); //\r
- * have a bash at finding the products amongst all the retrieved\r
+ * System.out.println("Search DS Xref for: "+(dna ? "dna" : "prot"));\r
+ * // have a bash at finding the products amongst all the retrieved\r
* sequences. SequenceI[] prod =\r
* jalview.analysis.CrossRef.findXrefSequences(al\r
* .getSequencesArray(), dna, null, ds); System.out.println("Found " +\r
* ((prod == null) ? "no" : "" + prod.length) + " products"); if\r
* (prod!=null) { // select non-equivalent sequences from dataset list\r
- * for (int p=0; p<prod.length; p++) { System.out.println("Prod\r
- * "+p+": "+prod[p].getDisplayId(true)); } } } }\r
+ * for (int p=0; p<prod.length; p++) { System.out.println("Prod "+p+":\r
+ * "+prod[p].getDisplayId(true)); } } } }\r
*/\r
}\r