X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=d737bd5adace0eb6145e5363526236a0872f1ff6;hb=a24dd1c4927582a629b2ce43c3786abe1c247847;hp=34f8f6edc75ca1b48ad24d53d79f309b83faa125;hpb=36dceb54710feb97a81f4bd69ad051f316141dc3;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 34f8f6e..d737bd5 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -30,7 +30,6 @@ import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.Hashtable; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -110,7 +109,10 @@ public class Alignment implements AlignmentI /* * Share the same dataset sequence mappings (if any). */ - this.setCodonFrames(al.getCodonFrames()); + if (dataset == null && al.getDataset() == null) + { + this.setCodonFrames(al.getCodonFrames()); + } } /** @@ -1293,22 +1295,6 @@ public class Alignment implements AlignmentI } } - /** - * adds a set of mappings (while ignoring any duplicates) - */ - @Override - public void addCodonFrames(Iterable codons) - { - if (codons != null) - { - Iterator it = codons.iterator(); - while (it.hasNext()) - { - addCodonFrame(it.next()); - } - } - } - /* * (non-Javadoc) * @@ -1387,11 +1373,7 @@ public class Alignment implements AlignmentI @Override public void append(AlignmentI toappend) { - if (toappend == this) - { - System.err.println("Self append may cause a deadlock."); - } - // TODO test this method for a future 2.5 release + // TODO JAL-1270 needs test coverage // currently tested for use in jalview.gui.SequenceFetcher boolean samegap = toappend.getGapCharacter() == getGapCharacter(); char oldc = toappend.getGapCharacter(); @@ -1402,6 +1384,8 @@ public class Alignment implements AlignmentI .getFullAlignment().getSequences() : toappend.getSequences(); if (sqs != null) { + // avoid self append deadlock by + List toappendsq = new ArrayList(); synchronized (sqs) { for (SequenceI addedsq : sqs) @@ -1417,9 +1401,13 @@ public class Alignment implements AlignmentI } } } - addSequence(addedsq); + toappendsq.add(addedsq); } } + for (SequenceI addedsq : toappendsq) + { + addSequence(addedsq); + } } AlignmentAnnotation[] alan = toappend.getAlignmentAnnotation(); for (int a = 0; alan != null && a < alan.length; a++) @@ -1427,6 +1415,7 @@ public class Alignment implements AlignmentI addAnnotation(alan[a]); } + // use add method getCodonFrames().addAll(toappend.getCodonFrames()); List sg = toappend.getGroups(); @@ -1717,9 +1706,11 @@ public class Alignment implements AlignmentI * Parameters control whether gaps in exon (mapped) and intron (unmapped) * regions are preserved. Gaps that connect introns to exons are treated * conservatively, i.e. only preserved if both intron and exon gaps are - * preserved. + * preserved. TODO: check caveats below where the implementation fails * * @param al + * - must have same dataset, and sequences in al must have equivalent + * dataset sequence and start/end bounds under given mapping * @param preserveMappedGaps * if true, gaps within and between mapped codons are preserved * @param preserveUnmappedGaps @@ -1736,6 +1727,10 @@ public class Alignment implements AlignmentI { return AlignmentUtils.alignProteinAsDna(this, al); } + else if (thatIsProtein && thisIsNucleotide) + { + return AlignmentUtils.alignCdsAsProtein(this, al); + } return AlignmentUtils.alignAs(this, al); }