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;
+ }
}