X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignmentUtils.java;fp=src%2Fjalview%2Fanalysis%2FAlignmentUtils.java;h=d8ebc7980b7eee5efd232769f030f8d4acad095a;hb=007dbbfcbbceb839a7928cd962b5a0837339c0d5;hp=6f0125d97eb5e287aae5f90fc8d9a359375bd1d1;hpb=2476d30e443b80cddbc953dd5285968a964eb42a;p=jalview.git diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 6f0125d..d8ebc79 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -37,6 +37,7 @@ import jalview.datamodel.AlignedCodon; 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; @@ -54,7 +55,6 @@ import jalview.util.MapList; */ public class AlignmentUtils { - /** * given an existing alignment, create a new alignment including all, or up to * flankSize additional symbols from each sequence's dataset sequence @@ -282,7 +282,7 @@ public class AlignmentUtils * 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; } @@ -1212,4 +1212,49 @@ public class AlignmentUtils } } } + + /** + * 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) + { + // Method moved here from CrossRef as the latter class has dependencies + // which break the applet build + 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; + } }