X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FCrossRef.java;h=6c63f1c009a3078751f15f09ec02c9995f761e21;hb=b57a02c25e335d033c97f8a6bacd6b54f62bd2b6;hp=8682e8abe7bc34c8a92e00c5b46f139134a469d9;hpb=8a6fa9ea9900d0f106529c3f6283e7f9d76dd2cb;p=jalview.git
diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java
index 8682e8a..6c63f1c 100644
--- a/src/jalview/analysis/CrossRef.java
+++ b/src/jalview/analysis/CrossRef.java
@@ -1,23 +1,24 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
- *
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ *
* 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
+ * 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
+ *
+ * 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 .
*/
package jalview.analysis;
import java.util.Enumeration;
+import java.util.List;
import java.util.Vector;
import java.util.Hashtable;
@@ -486,79 +487,82 @@ public class CrossRef
System.err.println("Empty dataset sequence set - NO VECTOR");
return false;
}
- Enumeration e = dataset.getSequences().elements();
- while (e.hasMoreElements())
+ List ds;
+ synchronized (ds = dataset.getSequences())
{
- SequenceI nxt = (SequenceI) e.nextElement();
- if (nxt != null)
- {
- if (nxt.getDatasetSequence() != null)
- {
- System.err
- .println("Implementation warning: getProducts passed a dataset alignment without dataset sequences in it!");
- }
- if (nxt != sequenceI && nxt != sequenceI.getDatasetSequence())
+ for (SequenceI nxt : ds)
+ if (nxt != null)
{
- // check if this is the correct sequence type
+ if (nxt.getDatasetSequence() != null)
{
- typer[0] = nxt;
- boolean isDna = jalview.util.Comparison.isNucleotide(typer);
- if ((direct && isDna == dna) || (!direct && isDna != dna))
+ System.err
+ .println("Implementation warning: getProducts passed a dataset alignment without dataset sequences in it!");
+ }
+ if (nxt != sequenceI && nxt != sequenceI.getDatasetSequence())
+ {
+ // check if this is the correct sequence type
{
- // skip this sequence because it is same molecule type
- continue;
+ typer[0] = nxt;
+ boolean isDna = jalview.util.Comparison.isNucleotide(typer);
+ if ((direct && isDna == dna) || (!direct && isDna != dna))
+ {
+ // skip this sequence because it is same molecule type
+ continue;
+ }
}
- }
- // look for direct or indirect references in common
- DBRefEntry[] poss = nxt.getDBRef(), cands = null;
- if (direct)
- {
- cands = jalview.util.DBRefUtils.searchRefs(poss, xrf);
- }
- else
- {
- poss = CrossRef.findXDbRefs(dna, poss); //
- cands = jalview.util.DBRefUtils.searchRefs(poss, xrf);
- }
- if (cands != null)
- {
- if (!rseqs.contains(nxt))
+ // look for direct or indirect references in common
+ DBRefEntry[] poss = nxt.getDBRef(), cands = null;
+ if (direct)
+ {
+ cands = jalview.util.DBRefUtils.searchRefs(poss, xrf);
+ }
+ else
{
- rseqs.addElement(nxt);
- boolean foundmap = cf != null; // don't search if we aren't given
- // a codon map object
- for (int r = 0; foundmap && r < cands.length; r++)
+ poss = CrossRef.findXDbRefs(dna, poss); //
+ cands = jalview.util.DBRefUtils.searchRefs(poss, xrf);
+ }
+ if (cands != null)
+ {
+ if (!rseqs.contains(nxt))
{
- if (cands[r].hasMap())
+ rseqs.addElement(nxt);
+ boolean foundmap = cf != null; // don't search if we aren't
+ // given
+ // a codon map object
+ for (int r = 0; foundmap && r < cands.length; r++)
{
- if (cands[r].getMap().getTo() != null
- && cands[r].getMap().getMap().getFromRatio() != cands[r]
- .getMap().getMap().getToRatio())
+ if (cands[r].hasMap())
{
- foundmap = true;
- // get sense of map correct for adding to product alignment.
- if (dna)
- {
- // map is from dna seq to a protein product
- cf.addMap(sequenceI, nxt, cands[r].getMap().getMap());
- }
- else
+ if (cands[r].getMap().getTo() != null
+ && cands[r].getMap().getMap().getFromRatio() != cands[r]
+ .getMap().getMap().getToRatio())
{
- // map should be from protein seq to its coding dna
- cf.addMap(nxt, sequenceI, cands[r].getMap().getMap()
- .getInverse());
+ foundmap = true;
+ // get sense of map correct for adding to product
+ // alignment.
+ if (dna)
+ {
+ // map is from dna seq to a protein product
+ cf.addMap(sequenceI, nxt, cands[r].getMap()
+ .getMap());
+ }
+ else
+ {
+ // map should be from protein seq to its coding dna
+ cf.addMap(nxt, sequenceI, cands[r].getMap()
+ .getMap().getInverse());
+ }
}
}
}
+ // TODO: add mapping between sequences if necessary
+ found = true;
}
- // TODO: add mapping between sequences if necessary
- found = true;
}
- }
+ }
}
- }
}
return found;
}