import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
import jalview.datamodel.Mapping;
import jalview.datamodel.SearchResults;
import jalview.datamodel.Sequence;
* many-to-many, as that would risk mixing species with similar cDNA
* sequences.
*/
- if (xrefsOnly && !CrossRef.haveCrossRef(aaSeq, cdnaSeq))
+ if (xrefsOnly && !AlignmentUtils.haveCrossRef(aaSeq, cdnaSeq))
{
continue;
}
}
}
}
+
+ /**
+ * Returns true if either sequence has a cross-reference to the other
+ *
+ * @param seq1
+ * @param seq2
+ * @return
+ */
+ public static boolean haveCrossRef(SequenceI seq1, SequenceI seq2)
+ {
+ // Note: moved here from class CrossRef as the latter class has dependencies
+ // not availability to the applet's classpath
+ return hasCrossRef(seq1, seq2) || hasCrossRef(seq2, seq1);
+ }
+
+ /**
+ * Returns true if seq1 has a cross-reference to seq2. Currently this assumes
+ * that sequence name is structured as Source|AccessId.
+ *
+ * @param seq1
+ * @param seq2
+ * @return
+ */
+ public static boolean hasCrossRef(SequenceI seq1, SequenceI seq2)
+ {
+ if (seq1 == null || seq2 == null)
+ {
+ return false;
+ }
+ String name = seq2.getName();
+ final DBRefEntry[] xrefs = seq1.getDBRef();
+ if (xrefs != null)
+ {
+ for (DBRefEntry xref : xrefs)
+ {
+ String xrefName = xref.getSource() + "|" + xref.getAccessionId();
+ // case-insensitive test, consistent with DBRefEntry.equalRef()
+ if (xrefName.equalsIgnoreCase(name))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
}
/**
- * Returns true if either sequence has a cross-reference to the other
- *
- * @param seq1
- * @param seq2
- * @return
- */
- public static boolean haveCrossRef(SequenceI seq1, SequenceI seq2)
- {
- return hasCrossRef(seq1, seq2) || hasCrossRef(seq2, seq1);
- }
-
- /**
- * Returns true if seq1 has a cross-reference to seq2. Currently this assumes
- * that sequence name is structured as Source|AccessId.
- *
- * @param seq1
- * @param seq2
- * @return
- */
- public static boolean hasCrossRef(SequenceI seq1, SequenceI seq2)
- {
- if (seq1 == null || seq2 == null)
- {
- return false;
- }
- String name = seq2.getName();
- final DBRefEntry[] xrefs = seq1.getDBRef();
- if (xrefs != null)
- {
- for (DBRefEntry xref : xrefs)
- {
- String xrefName = xref.getSource() + "|" + xref.getAccessionId();
- // case-insensitive test, consistent with DBRefEntry.equalRef()
- if (xrefName.equalsIgnoreCase(name))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
* precalculate different products that can be found for seqs in dataset and
* return them.
*
*/
package jalview.analysis;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
import jalview.api.AlignViewportI;
-import jalview.bin.Cache;
import jalview.datamodel.AlignedCodon;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.util.MapList;
import jalview.util.ShiftList;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
public class Dna
{
private static final String STOP_X = "X";
if (rf != 0)
{
final String errMsg = "trimming contigs for incomplete terminal codon.";
- if (Cache.log != null)
- {
- Cache.log.debug(errMsg);
- }
- else
- {
- System.err.println(errMsg);
- }
+ System.err.println(errMsg);
// map and trim contigs to ORF region
vc = scontigs.length - 1;
lastnpos = vismapping.shift(lastnpos); // place npos in context of
assertFalse(ann5.visible);
assertTrue(ann6.visible); // not sequence-related, not affected
}
+
+ /**
+ * Tests for the method that checks if one sequence cross-references another
+ */
+ @Test
+ public void testHasCrossRef()
+ {
+ assertFalse(AlignmentUtils.hasCrossRef(null, null));
+ SequenceI seq1 = new Sequence("EMBL|A12345", "ABCDEF");
+ assertFalse(AlignmentUtils.hasCrossRef(seq1, null));
+ assertFalse(AlignmentUtils.hasCrossRef(null, seq1));
+ SequenceI seq2 = new Sequence("UNIPROT|V20192", "ABCDEF");
+ assertFalse(AlignmentUtils.hasCrossRef(seq1, seq2));
+
+ // different ref
+ seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "v20193"));
+ assertFalse(AlignmentUtils.hasCrossRef(seq1, seq2));
+
+ // case-insensitive; version number is ignored
+ seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "v20192"));
+ assertTrue(AlignmentUtils.hasCrossRef(seq1, seq2));
+
+ // right case!
+ seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "V20192"));
+ assertTrue(AlignmentUtils.hasCrossRef(seq1, seq2));
+ // test is one-way only
+ assertFalse(AlignmentUtils.hasCrossRef(seq2, seq1));
+ }
+
+ /**
+ * Tests for the method that checks if either sequence cross-references the
+ * other
+ */
+ @Test
+ public void testHaveCrossRef()
+ {
+ assertFalse(AlignmentUtils.hasCrossRef(null, null));
+ SequenceI seq1 = new Sequence("EMBL|A12345", "ABCDEF");
+ assertFalse(AlignmentUtils.haveCrossRef(seq1, null));
+ assertFalse(AlignmentUtils.haveCrossRef(null, seq1));
+ SequenceI seq2 = new Sequence("UNIPROT|V20192", "ABCDEF");
+ assertFalse(AlignmentUtils.haveCrossRef(seq1, seq2));
+
+ seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "V20192"));
+ assertTrue(AlignmentUtils.haveCrossRef(seq1, seq2));
+ // next is true for haveCrossRef, false for hasCrossRef
+ assertTrue(AlignmentUtils.haveCrossRef(seq2, seq1));
+
+ // now the other way round
+ seq1.setDBRef(null);
+ seq2.addDBRef(new DBRefEntry("EMBL", "1", "A12345"));
+ assertTrue(AlignmentUtils.haveCrossRef(seq1, seq2));
+ assertTrue(AlignmentUtils.haveCrossRef(seq2, seq1));
+
+ // now both ways
+ seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "V20192"));
+ assertTrue(AlignmentUtils.haveCrossRef(seq1, seq2));
+ assertTrue(AlignmentUtils.haveCrossRef(seq2, seq1));
+ }
}
+++ /dev/null
-package jalview.analysis;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import jalview.datamodel.DBRefEntry;
-import jalview.datamodel.Sequence;
-import jalview.datamodel.SequenceI;
-
-import org.junit.Test;
-
-public class CrossRefTest
-{
-
- /**
- * Tests for the method that checks if one sequence cross-references another
- */
- @Test
- public void testHasCrossRef()
- {
- assertFalse(CrossRef.hasCrossRef(null, null));
- SequenceI seq1 = new Sequence("EMBL|A12345", "ABCDEF");
- assertFalse(CrossRef.hasCrossRef(seq1, null));
- assertFalse(CrossRef.hasCrossRef(null, seq1));
- SequenceI seq2 = new Sequence("UNIPROT|V20192", "ABCDEF");
- assertFalse(CrossRef.hasCrossRef(seq1, seq2));
-
- // different ref
- seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "v20193"));
- assertFalse(CrossRef.hasCrossRef(seq1, seq2));
-
- // case-insensitive; version number is ignored
- seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "v20192"));
- assertTrue(CrossRef.hasCrossRef(seq1, seq2));
-
- // right case!
- seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "V20192"));
- assertTrue(CrossRef.hasCrossRef(seq1, seq2));
- // test is one-way only
- assertFalse(CrossRef.hasCrossRef(seq2, seq1));
- }
-
- /**
- * Tests for the method that checks if either sequence cross-references the
- * other
- */
- @Test
- public void testHaveCrossRef()
- {
- assertFalse(CrossRef.hasCrossRef(null, null));
- SequenceI seq1 = new Sequence("EMBL|A12345", "ABCDEF");
- assertFalse(CrossRef.haveCrossRef(seq1, null));
- assertFalse(CrossRef.haveCrossRef(null, seq1));
- SequenceI seq2 = new Sequence("UNIPROT|V20192", "ABCDEF");
- assertFalse(CrossRef.haveCrossRef(seq1, seq2));
-
- seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "V20192"));
- assertTrue(CrossRef.haveCrossRef(seq1, seq2));
- // next is true for haveCrossRef, false for hasCrossRef
- assertTrue(CrossRef.haveCrossRef(seq2, seq1));
-
- // now the other way round
- seq1.setDBRef(null);
- seq2.addDBRef(new DBRefEntry("EMBL", "1", "A12345"));
- assertTrue(CrossRef.haveCrossRef(seq1, seq2));
- assertTrue(CrossRef.haveCrossRef(seq2, seq1));
-
- // now both ways
- seq1.addDBRef(new DBRefEntry("UNIPROT", "1", "V20192"));
- assertTrue(CrossRef.haveCrossRef(seq1, seq2));
- assertTrue(CrossRef.haveCrossRef(seq2, seq1));
- }
-}