X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignmentOrder.java;h=639dd470fba2e157f9cd4d61962e5bc9d039fa03;hb=d587f1aa61946dc14f6f089cf1dc2a3116cfb773;hp=231009ae807eec9dc3e016d64d3f0e0d61c575af;hpb=4eefb40838faa0a3c03be3480ff74ba2ac67a5c1;p=jalview.git diff --git a/src/jalview/datamodel/AlignmentOrder.java b/src/jalview/datamodel/AlignmentOrder.java index 231009a..639dd47 100755 --- a/src/jalview/datamodel/AlignmentOrder.java +++ b/src/jalview/datamodel/AlignmentOrder.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -171,7 +171,7 @@ public class AlignmentOrder * replaces oldref with newref in the alignment order. * @param oldref * @param newref - * @return + * @return true if oldref was contained in order and replaced with newref */ public boolean updateSequence(SequenceI oldref, SequenceI newref) { int found=Order.indexOf(oldref); @@ -181,6 +181,85 @@ public class AlignmentOrder return found>-1; } /** + * Exact equivalence of two AlignmentOrders + * @param o + * @return true if o orders the same sequenceI objects in the same way + */ + public boolean equals(AlignmentOrder o) { + return equals(o, true); + } + /** + * Exact equivalence of two AlignmentOrders + * // TODO: Weak SequenceI equivalence - will throw Error at moment + * @param o + * @param identity - false - use weak equivalence (refers to same or different parts of same sequence) + * @return true if o orders equivalent sequenceI objects in the same way + */ + public boolean equals(AlignmentOrder o, boolean identity) { + if (o!=this) { + if (o==null) + return false; + if (Order!=null && o.Order!=null && Order.size()==o.Order.size()) { + if (!identity) { + throw new Error("Weak sequenceI equivalence not yet implemented."); + } else { + for (int i=0,j=o.Order.size(); iOrder.size()) { + c = o.Order; + s = Order; + } else { + c = Order; + s = o.Order; + } + if (!identity) { + throw new Error("Weak sequenceI equivalence not yet implemented."); + } else { + // test if c contains s and order in s is conserved in c + int last=-1; + for (int i=0,j=s.size(); ilast) { + last=pos; + } else + return false; + } + } + } else + return false; + } + return true; + } + /** * AlignmentOrder * * @param orderThis AlignmentI