X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignmentUtils.java;h=0906872507a184e146456f5891062aa2e0c66076;hb=84ff3a3c7824890b0a201e6a4ec8fa1c9b6e9e64;hp=fdc74e2fed6f1f8cf4ba65a040c99374255163c0;hpb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;p=jalview.git diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index fdc74e2..0906872 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -20,8 +20,6 @@ */ package jalview.analysis; -import java.util.Locale; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -31,6 +29,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.NoSuchElementException; @@ -46,6 +45,7 @@ import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; +import jalview.datamodel.ContactMatrixI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.GeneLociI; import jalview.datamodel.IncompleteCodonException; @@ -184,10 +184,10 @@ public class AlignmentUtils // TODO use Character.toLowerCase to avoid creating String objects? char[] upstream = new String(ds .getSequence(s.getStart() - 1 - ustream_ds, s.getStart() - 1)) - .toLowerCase(Locale.ROOT).toCharArray(); + .toLowerCase(Locale.ROOT).toCharArray(); char[] downstream = new String( ds.getSequence(s_end - 1, s_end + dstream_ds)) - .toLowerCase(Locale.ROOT).toCharArray(); + .toLowerCase(Locale.ROOT).toCharArray(); char[] coreseq = s.getSequence(); char[] nseq = new char[offset + upstream.length + downstream.length + coreseq.length]; @@ -1471,8 +1471,19 @@ public class AlignmentUtils */ final Iterable matchedAlignmentAnnotations = al .findAnnotations(seq, dsann.getCalcId(), dsann.label); - if (!matchedAlignmentAnnotations.iterator().hasNext()) + boolean found=false; + if (matchedAlignmentAnnotations != null) { + for (AlignmentAnnotation matched:matchedAlignmentAnnotations) + { + if (dsann.description.equals(matched.description)) + { + found=true; + break; + } + } + } + if (!found) { result.add(dsann); if (labelForCalcId != null) { @@ -1517,7 +1528,7 @@ public class AlignmentUtils startRes = selectionGroup.getStartRes(); endRes = selectionGroup.getEndRes(); } - copyAnn.restrict(startRes, endRes); + copyAnn.restrict(startRes, endRes + 0); /* * Add to the sequence (sets copyAnn.datasetSequence), unless the @@ -1525,6 +1536,12 @@ public class AlignmentUtils */ if (!seq.hasAnnotation(ann)) { + ContactMatrixI cm = seq.getDatasetSequence() + .getContactMatrixFor(ann); + if (cm != null) + { + seq.addContactListFor(copyAnn, cm); + } seq.addAlignmentAnnotation(copyAnn); } // adjust for gaps @@ -1534,6 +1551,7 @@ public class AlignmentUtils copyAnn.visible = true; } } + } /** @@ -1573,6 +1591,21 @@ public class AlignmentUtils } } + public static AlignmentAnnotation getFirstSequenceAnnotationOfType( + AlignmentI al, int graphType) + { + AlignmentAnnotation[] anns = al.getAlignmentAnnotation(); + if (anns != null) + { + for (AlignmentAnnotation aa : anns) + { + if (aa.sequenceRef != null && aa.graph == graphType) + return aa; + } + } + return null; + } + /** * Returns true if either sequence has a cross-reference to the other *