X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=cc21f35aa020b3d91a3ec6397f90cc70ab1985b4;hb=eb3e681d6e82ccdd5d312d1981dfb306e7f479f0;hp=cbd17c8c1b7b85300766db30f8e5e8c15371f1d1;hpb=bc71cfb740ebb5788ed0d2eb4de5337c1337525e;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index cbd17c8..cc21f35 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -33,6 +33,8 @@ import java.util.Vector; import fr.orsay.lri.varna.models.rna.RNA; import jalview.analysis.AlignSeq; +import jalview.analysis.AlignmentUtils; +import jalview.analysis.SeqsetUtils; import jalview.datamodel.features.SequenceFeatures; import jalview.datamodel.features.SequenceFeaturesI; import jalview.util.Comparison; @@ -172,7 +174,7 @@ public class Sequence extends ASequence implements SequenceI { if (name == null) { - System.err.println( + jalview.bin.Console.errPrintln( "POSSIBLE IMPLEMENTATION ERROR: null sequence name passed to constructor."); name = ""; } @@ -350,6 +352,11 @@ public class Sequence extends ASequence implements SequenceI { // only copy the given annotation AlignmentAnnotation newann = new AlignmentAnnotation(sqann[i]); + ContactMatrixI cm = seq.getContactMatrixFor(sqann[i]); + if (cm != null) + { + addContactListFor(newann, cm); + } addAlignmentAnnotation(newann); } } @@ -380,7 +387,7 @@ public class Sequence extends ASequence implements SequenceI { if (sf.getType() == null) { - System.err.println( + jalview.bin.Console.errPrintln( "SequenceFeature type may not be null: " + sf.toString()); return false; } @@ -1627,14 +1634,19 @@ public class Sequence extends ASequence implements SequenceI // sequence-column mapping datasetSequence.addAlignmentAnnotation(_aa); - // transfer contact matrices - ContactMatrixI cm = getContactMatrixFor(aa); - if (cm != null) - { - datasetSequence.addContactListFor(_aa, cm); + if (_cmholder != null) + { // transfer contact matrices + ContactMatrixI cm = _cmholder.getContactMatrixFor(aa); + if (cm != null) + { + datasetSequence.addContactListFor(_aa, cm); + datasetSequence.addContactListFor(aa, cm); + } } } } + // all matrices should have been transferred. so we clear the local holder + _cmholder = null; } return datasetSequence; } @@ -1742,6 +1754,14 @@ public class Sequence extends ASequence implements SequenceI transferAnnotation(entry.getDatasetSequence(), mp); return; } + // transfer from entry to sequence + // if entry has a description and sequence doesn't, then transfer + if (entry.getDescription() != null + && (description == null || description.trim().length() == 0)) + { + description = entry.getDescription(); + } + // transfer any new features from entry onto sequence if (entry.getSequenceFeatures() != null) { @@ -2119,40 +2139,69 @@ public class Sequence extends ASequence implements SequenceI //// //// Contact Matrix Holder Boilerplate //// - ContactMapHolderI cmholder = new ContactMapHolder(); + ContactMapHolderI _cmholder = null; + + private ContactMapHolderI getContactMapHolder() + { + if (datasetSequence != null) + { + return ((Sequence) datasetSequence).getContactMapHolder(); + } + if (_cmholder == null) + { + _cmholder = new ContactMapHolder(); + } + return _cmholder; + } @Override public Collection getContactMaps() { - return cmholder.getContactMaps(); + return getContactMapHolder().getContactMaps(); } @Override public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann) { - return cmholder.getContactMatrixFor(ann); + return getContactMapHolder().getContactMatrixFor(ann); } @Override public ContactListI getContactListFor(AlignmentAnnotation _aa, int column) { - return cmholder.getContactListFor(_aa, column); + return getContactMapHolder().getContactListFor(_aa, column); } @Override public AlignmentAnnotation addContactList(ContactMatrixI cm) { - AlignmentAnnotation aa = cmholder.addContactList(cm); + AlignmentAnnotation aa; + + if (datasetSequence != null) + { + aa = datasetSequence.addContactList(cm); + // clone the annotation for the local sequence + aa = new AlignmentAnnotation(aa); + aa.restrict(start, end); + aa.adjustForAlignment(); + getContactMapHolder().addContactListFor(aa, cm); + addAlignmentAnnotation(aa); + return aa; + } + + // construct new annotation for matrix on dataset sequence + aa = getContactMapHolder().addContactList(cm); Annotation _aa[] = new Annotation[getLength()]; - + for (int i = 0; i < _aa.length; _aa[i++] = new Annotation(0.0f)) { ; } aa.annotations = _aa; aa.setSequenceRef(this); - if (cm instanceof MappableContactMatrix && !((MappableContactMatrix) cm).hasReferenceSeq()) + if (cm instanceof MappableContactMatrix + && !((MappableContactMatrix) cm).hasReferenceSeq()) { ((MappableContactMatrix) cm).setRefSeq(this); } @@ -2165,6 +2214,6 @@ public class Sequence extends ASequence implements SequenceI public void addContactListFor(AlignmentAnnotation annotation, ContactMatrixI cm) { - cmholder.addContactListFor(annotation, cm); + getContactMapHolder().addContactListFor(annotation, cm); } }