2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import jalview.analysis.AlignSeq;
24 import jalview.api.DBRefEntryI;
25 import jalview.datamodel.features.SequenceFeatures;
26 import jalview.datamodel.features.SequenceFeaturesI;
27 import jalview.util.Comparison;
28 import jalview.util.DBRefUtils;
29 import jalview.util.MapList;
30 import jalview.util.StringUtils;
32 import java.util.ArrayList;
33 import java.util.Arrays;
34 import java.util.BitSet;
35 import java.util.Collections;
36 import java.util.Enumeration;
37 import java.util.List;
38 import java.util.ListIterator;
39 import java.util.Vector;
41 import com.stevesoft.pat.Regex;
43 import fr.orsay.lri.varna.models.rna.RNA;
47 * Implements the SequenceI interface for a char[] based sequence object.
52 public class Sequence extends ASequence implements SequenceI
54 private static final Regex limitrx = new Regex(
55 "[/][0-9]{1,}[-][0-9]{1,}$");
57 private static final Regex endrx = new Regex("[0-9]{1,}$");
59 SequenceI datasetSequence;
63 private char[] sequence;
71 Vector<PDBEntry> pdbIds;
80 * This annotation is displayed below the alignment but the positions are tied
81 * to the residues of this sequence
83 * TODO: change to List<>
85 Vector<AlignmentAnnotation> annotation;
88 * The index of the sequence in a MSA
92 private SequenceFeatures sequenceFeatureStore;
95 * Creates a new Sequence object.
100 * string to form a possibly gapped sequence out of
102 * first position of non-gap residue in the sequence
104 * last position of ungapped residues (nearly always only used for
107 public Sequence(String name, String sequence, int start, int end)
110 initSeqAndName(name, sequence.toCharArray(), start, end);
113 public Sequence(String name, char[] sequence, int start, int end)
116 initSeqAndName(name, sequence, start, end);
120 * Stage 1 constructor - assign name, sequence, and set start and end fields.
121 * start and end are updated values from name2 if it ends with /start-end
128 protected void initSeqAndName(String name2, char[] sequence2, int start2,
132 this.sequence = sequence2;
144 .println("POSSIBLE IMPLEMENTATION ERROR: null sequence name passed to constructor.");
147 // Does sequence have the /start-end signature?
148 if (limitrx.search(name))
150 name = limitrx.left();
151 endrx.search(limitrx.stringMatched());
152 setStart(Integer.parseInt(limitrx.stringMatched().substring(1,
153 endrx.matchedFrom() - 1)));
154 setEnd(Integer.parseInt(endrx.stringMatched()));
158 void checkValidRange()
161 // http://issues.jalview.org/browse/JAL-774?focusedCommentId=11239&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-11239
164 for (int j = 0; j < sequence.length; j++)
166 if (!jalview.util.Comparison.isGap(sequence[j]))
185 * default constructor
189 sequenceFeatureStore = new SequenceFeatures();
193 * Creates a new Sequence object.
200 public Sequence(String name, String sequence)
202 this(name, sequence, 1, -1);
206 * Creates a new Sequence object with new AlignmentAnnotations but inherits
207 * any existing dataset sequence reference. If non exists, everything is
211 * if seq is a dataset sequence, behaves like a plain old copy
214 public Sequence(SequenceI seq)
216 this(seq, seq.getAnnotation());
220 * Create a new sequence object with new features, DBRefEntries, and PDBIds
221 * but inherits any existing dataset sequence reference, and duplicate of any
222 * annotation that is present in the given annotation array.
225 * the sequence to be copied
226 * @param alAnnotation
227 * an array of annotation including some associated with seq
229 public Sequence(SequenceI seq, AlignmentAnnotation[] alAnnotation)
232 initSeqFrom(seq, alAnnotation);
236 * does the heavy lifting when cloning a dataset sequence, or coping data from
237 * dataset to a new derived sequence.
240 * - source of attributes.
241 * @param alAnnotation
242 * - alignment annotation present on seq that should be copied onto
245 protected void initSeqFrom(SequenceI seq,
246 AlignmentAnnotation[] alAnnotation)
248 char[] oseq = seq.getSequence();
249 initSeqAndName(seq.getName(), Arrays.copyOf(oseq, oseq.length),
250 seq.getStart(), seq.getEnd());
252 description = seq.getDescription();
253 if (seq != datasetSequence)
255 setDatasetSequence(seq.getDatasetSequence());
259 * only copy DBRefs and seqfeatures if we really are a dataset sequence
261 if (datasetSequence == null)
263 if (seq.getDBRefs() != null)
265 DBRefEntry[] dbr = seq.getDBRefs();
266 for (int i = 0; i < dbr.length; i++)
268 addDBRef(new DBRefEntry(dbr[i]));
273 * make copies of any sequence features
275 for (SequenceFeature sf : seq.getSequenceFeatures())
277 addSequenceFeature(new SequenceFeature(sf));
281 if (seq.getAnnotation() != null)
283 AlignmentAnnotation[] sqann = seq.getAnnotation();
284 for (int i = 0; i < sqann.length; i++)
286 if (sqann[i] == null)
290 boolean found = (alAnnotation == null);
293 for (int apos = 0; !found && apos < alAnnotation.length; apos++)
295 found = (alAnnotation[apos] == sqann[i]);
300 // only copy the given annotation
301 AlignmentAnnotation newann = new AlignmentAnnotation(sqann[i]);
302 addAlignmentAnnotation(newann);
306 if (seq.getAllPDBEntries() != null)
308 Vector<PDBEntry> ids = seq.getAllPDBEntries();
309 for (PDBEntry pdb : ids)
311 this.addPDBId(new PDBEntry(pdb));
317 public void setSequenceFeatures(List<SequenceFeature> features)
319 if (datasetSequence != null)
321 datasetSequence.setSequenceFeatures(features);
324 sequenceFeatureStore = new SequenceFeatures(features);
328 public synchronized boolean addSequenceFeature(SequenceFeature sf)
330 if (sf.getType() == null)
332 System.err.println("SequenceFeature type may not be null: "
337 if (datasetSequence != null)
339 return datasetSequence.addSequenceFeature(sf);
342 return sequenceFeatureStore.add(sf);
346 public void deleteFeature(SequenceFeature sf)
348 if (datasetSequence != null)
350 datasetSequence.deleteFeature(sf);
354 sequenceFeatureStore.delete(sf);
364 public List<SequenceFeature> getSequenceFeatures()
366 if (datasetSequence != null)
368 return datasetSequence.getSequenceFeatures();
370 return sequenceFeatureStore.getAllFeatures();
374 public SequenceFeaturesI getFeatures()
376 return datasetSequence != null ? datasetSequence.getFeatures()
377 : sequenceFeatureStore;
381 public boolean addPDBId(PDBEntry entry)
385 pdbIds = new Vector<PDBEntry>();
390 for (PDBEntry pdbe : pdbIds)
392 if (pdbe.updateFrom(entry))
397 pdbIds.addElement(entry);
408 public void setPDBId(Vector<PDBEntry> id)
416 * @return DOCUMENT ME!
419 public Vector<PDBEntry> getAllPDBEntries()
421 return pdbIds == null ? new Vector<PDBEntry>() : pdbIds;
427 * @return DOCUMENT ME!
430 public String getDisplayId(boolean jvsuffix)
432 StringBuffer result = new StringBuffer(name);
435 result.append("/" + start + "-" + end);
438 return result.toString();
448 public void setName(String name)
457 * @return DOCUMENT ME!
460 public String getName()
472 public void setStart(int start)
480 * @return DOCUMENT ME!
483 public int getStart()
495 public void setEnd(int end)
503 * @return DOCUMENT ME!
514 * @return DOCUMENT ME!
517 public int getLength()
519 return this.sequence.length;
529 public void setSequence(String seq)
531 this.sequence = seq.toCharArray();
536 public String getSequenceAsString()
538 return new String(sequence);
542 public String getSequenceAsString(int start, int end)
544 return new String(getSequence(start, end));
548 public char[] getSequence()
556 * @see jalview.datamodel.SequenceI#getSequence(int, int)
559 public char[] getSequence(int start, int end)
565 // JBPNote - left to user to pad the result here (TODO:Decide on this
567 if (start >= sequence.length)
572 if (end >= sequence.length)
574 end = sequence.length;
577 char[] reply = new char[end - start];
578 System.arraycopy(sequence, start, reply, 0, end - start);
584 public SequenceI getSubSequence(int start, int end)
590 char[] seq = getSequence(start, end);
595 int nstart = findPosition(start);
596 int nend = findPosition(end) - 1;
597 // JBPNote - this is an incomplete copy.
598 SequenceI nseq = new Sequence(this.getName(), seq, nstart, nend);
599 nseq.setDescription(description);
600 if (datasetSequence != null)
602 nseq.setDatasetSequence(datasetSequence);
606 nseq.setDatasetSequence(this);
612 * Returns the character of the aligned sequence at the given position (base
613 * zero), or space if the position is not within the sequence's bounds
618 public char getCharAt(int i)
620 if (i >= 0 && i < sequence.length)
637 public void setDescription(String desc)
639 this.description = desc;
645 * @return DOCUMENT ME!
648 public String getDescription()
650 return this.description;
656 * @see jalview.datamodel.SequenceI#findIndex(int)
659 public int findIndex(int pos)
661 // returns the alignment position for a residue
664 // Rely on end being at least as long as the length of the sequence.
665 while ((i < sequence.length) && (j <= end) && (j <= pos))
667 if (!Comparison.isGap(sequence[i]))
675 if ((j == end) && (j < pos))
686 public int findPosition(int i)
690 int seqlen = sequence.length;
691 while ((j < i) && (j < seqlen))
693 if (!Comparison.isGap(sequence[j]))
705 * Returns an int array where indices correspond to each residue in the
706 * sequence and the element value gives its position in the alignment
708 * @return int[SequenceI.getEnd()-SequenceI.getStart()+1] or null if no
709 * residues in SequenceI object
712 public int[] gapMap()
714 String seq = jalview.analysis.AlignSeq.extractGaps(
715 jalview.util.Comparison.GapChars, new String(sequence));
716 int[] map = new int[seq.length()];
720 while (j < sequence.length)
722 if (!jalview.util.Comparison.isGap(sequence[j]))
734 public int[] findPositionMap()
736 int map[] = new int[sequence.length];
739 int seqlen = sequence.length;
743 if (!jalview.util.Comparison.isGap(sequence[j]))
754 public List<int[]> getInsertions()
756 ArrayList<int[]> map = new ArrayList<int[]>();
757 int lastj = -1, j = 0;
759 int seqlen = sequence.length;
762 if (jalview.util.Comparison.isGap(sequence[j]))
773 map.add(new int[] { lastj, j - 1 });
781 map.add(new int[] { lastj, j - 1 });
788 public BitSet getInsertionsAsBits()
790 BitSet map = new BitSet();
791 int lastj = -1, j = 0;
793 int seqlen = sequence.length;
796 if (jalview.util.Comparison.isGap(sequence[j]))
822 public void deleteChars(int i, int j)
824 int newstart = start, newend = end;
825 if (i >= sequence.length || i < 0)
830 char[] tmp = StringUtils.deleteChars(sequence, i, j);
831 boolean createNewDs = false;
832 // TODO: take a (second look) at the dataset creation validation method for
833 // the very large sequence case
834 int eindex = -1, sindex = -1;
835 boolean ecalc = false, scalc = false;
836 for (int s = i; s < j; s++)
838 if (jalview.schemes.ResidueProperties.aaIndex[sequence[s]] != 23)
848 sindex = findIndex(start) - 1;
853 // delete characters including start of sequence
854 newstart = findPosition(j);
855 break; // don't need to search for any more residue characters.
859 // delete characters after start.
862 eindex = findIndex(end) - 1;
867 // delete characters at end of sequence
868 newend = findPosition(i - 1);
869 break; // don't need to search for any more residue characters.
874 newend--; // decrease end position by one for the deleted residue
875 // and search further
881 // deletion occured in the middle of the sequence
882 if (createNewDs && this.datasetSequence != null)
884 // construct a new sequence
885 Sequence ds = new Sequence(datasetSequence);
886 // TODO: remove any non-inheritable properties ?
887 // TODO: create a sequence mapping (since there is a relation here ?)
888 ds.deleteChars(i, j);
889 datasetSequence = ds;
897 public void insertCharAt(int i, int length, char c)
899 char[] tmp = new char[sequence.length + length];
901 if (i >= sequence.length)
903 System.arraycopy(sequence, 0, tmp, 0, sequence.length);
908 System.arraycopy(sequence, 0, tmp, 0, i);
918 if (i < sequence.length)
920 System.arraycopy(sequence, i, tmp, index, sequence.length - i);
927 public void insertCharAt(int i, char c)
929 insertCharAt(i, 1, c);
933 public String getVamsasId()
939 public void setVamsasId(String id)
945 public void setDBRefs(DBRefEntry[] dbref)
947 if (dbrefs == null && datasetSequence != null
948 && this != datasetSequence)
950 datasetSequence.setDBRefs(dbref);
956 DBRefUtils.ensurePrimaries(this);
961 public DBRefEntry[] getDBRefs()
963 if (dbrefs == null && datasetSequence != null
964 && this != datasetSequence)
966 return datasetSequence.getDBRefs();
972 public void addDBRef(DBRefEntry entry)
974 if (datasetSequence != null)
976 datasetSequence.addDBRef(entry);
982 dbrefs = new DBRefEntry[0];
985 for (DBRefEntryI dbr : dbrefs)
987 if (dbr.updateFrom(entry))
990 * found a dbref that either matched, or could be
991 * updated from, the new entry - no need to add it
998 * extend the array to make room for one more
1000 // TODO use an ArrayList instead
1001 int j = dbrefs.length;
1002 DBRefEntry[] temp = new DBRefEntry[j + 1];
1003 System.arraycopy(dbrefs, 0, temp, 0, j);
1004 temp[temp.length - 1] = entry;
1008 DBRefUtils.ensurePrimaries(this);
1012 public void setDatasetSequence(SequenceI seq)
1016 throw new IllegalArgumentException(
1017 "Implementation Error: self reference passed to SequenceI.setDatasetSequence");
1019 if (seq != null && seq.getDatasetSequence() != null)
1021 throw new IllegalArgumentException(
1022 "Implementation error: cascading dataset sequences are not allowed.");
1024 datasetSequence = seq;
1028 public SequenceI getDatasetSequence()
1030 return datasetSequence;
1034 public AlignmentAnnotation[] getAnnotation()
1036 return annotation == null ? null : annotation
1037 .toArray(new AlignmentAnnotation[annotation.size()]);
1041 public boolean hasAnnotation(AlignmentAnnotation ann)
1043 return annotation == null ? false : annotation.contains(ann);
1047 public void addAlignmentAnnotation(AlignmentAnnotation annotation)
1049 if (this.annotation == null)
1051 this.annotation = new Vector<AlignmentAnnotation>();
1053 if (!this.annotation.contains(annotation))
1055 this.annotation.addElement(annotation);
1057 annotation.setSequenceRef(this);
1061 public void removeAlignmentAnnotation(AlignmentAnnotation annotation)
1063 if (this.annotation != null)
1065 this.annotation.removeElement(annotation);
1066 if (this.annotation.size() == 0)
1068 this.annotation = null;
1074 * test if this is a valid candidate for another sequence's dataset sequence.
1077 private boolean isValidDatasetSequence()
1079 if (datasetSequence != null)
1083 for (int i = 0; i < sequence.length; i++)
1085 if (jalview.util.Comparison.isGap(sequence[i]))
1094 public SequenceI deriveSequence()
1096 Sequence seq = null;
1097 if (datasetSequence == null)
1099 if (isValidDatasetSequence())
1101 // Use this as dataset sequence
1102 seq = new Sequence(getName(), "", 1, -1);
1103 seq.setDatasetSequence(this);
1104 seq.initSeqFrom(this, getAnnotation());
1109 // Create a new, valid dataset sequence
1110 createDatasetSequence();
1113 return new Sequence(this);
1116 private boolean _isNa;
1118 private long _seqhash = 0;
1121 * Answers false if the sequence is more than 85% nucleotide (ACGTU), else
1125 public boolean isProtein()
1127 if (datasetSequence != null)
1129 return datasetSequence.isProtein();
1131 if (_seqhash != sequence.hashCode())
1133 _seqhash = sequence.hashCode();
1134 _isNa = Comparison.isNucleotide(this);
1142 * @see jalview.datamodel.SequenceI#createDatasetSequence()
1145 public SequenceI createDatasetSequence()
1147 if (datasetSequence == null)
1149 Sequence dsseq = new Sequence(getName(), AlignSeq.extractGaps(
1150 jalview.util.Comparison.GapChars, getSequenceAsString()),
1151 getStart(), getEnd());
1153 datasetSequence = dsseq;
1155 dsseq.setDescription(description);
1156 // move features and database references onto dataset sequence
1157 dsseq.sequenceFeatureStore = sequenceFeatureStore;
1158 sequenceFeatureStore = null;
1159 dsseq.dbrefs = dbrefs;
1161 // TODO: search and replace any references to this sequence with
1162 // references to the dataset sequence in Mappings on dbref
1163 dsseq.pdbIds = pdbIds;
1165 datasetSequence.updatePDBIds();
1166 if (annotation != null)
1168 // annotation is cloned rather than moved, to preserve what's currently
1170 for (AlignmentAnnotation aa : annotation)
1172 AlignmentAnnotation _aa = new AlignmentAnnotation(aa);
1173 _aa.sequenceRef = datasetSequence;
1174 _aa.adjustForAlignment(); // uses annotation's own record of
1175 // sequence-column mapping
1176 datasetSequence.addAlignmentAnnotation(_aa);
1180 return datasetSequence;
1187 * jalview.datamodel.SequenceI#setAlignmentAnnotation(AlignmmentAnnotation[]
1191 public void setAlignmentAnnotation(AlignmentAnnotation[] annotations)
1193 if (annotation != null)
1195 annotation.removeAllElements();
1197 if (annotations != null)
1199 for (int i = 0; i < annotations.length; i++)
1201 if (annotations[i] != null)
1203 addAlignmentAnnotation(annotations[i]);
1210 public AlignmentAnnotation[] getAnnotation(String label)
1212 if (annotation == null || annotation.size() == 0)
1217 Vector<AlignmentAnnotation> subset = new Vector<AlignmentAnnotation>();
1218 Enumeration<AlignmentAnnotation> e = annotation.elements();
1219 while (e.hasMoreElements())
1221 AlignmentAnnotation ann = e.nextElement();
1222 if (ann.label != null && ann.label.equals(label))
1224 subset.addElement(ann);
1227 if (subset.size() == 0)
1231 AlignmentAnnotation[] anns = new AlignmentAnnotation[subset.size()];
1233 e = subset.elements();
1234 while (e.hasMoreElements())
1236 anns[i++] = e.nextElement();
1238 subset.removeAllElements();
1243 public boolean updatePDBIds()
1245 if (datasetSequence != null)
1247 // TODO: could merge DBRefs
1248 return datasetSequence.updatePDBIds();
1250 if (dbrefs == null || dbrefs.length == 0)
1254 boolean added = false;
1255 for (DBRefEntry dbr : dbrefs)
1257 if (DBRefSource.PDB.equals(dbr.getSource()))
1260 * 'Add' any PDB dbrefs as a PDBEntry - add is only performed if the
1261 * PDB id is not already present in a 'matching' PDBEntry
1262 * Constructor parses out a chain code if appended to the accession id
1263 * (a fudge used to 'store' the chain code in the DBRef)
1265 PDBEntry pdbe = new PDBEntry(dbr);
1266 added |= addPDBId(pdbe);
1273 public void transferAnnotation(SequenceI entry, Mapping mp)
1275 if (datasetSequence != null)
1277 datasetSequence.transferAnnotation(entry, mp);
1280 if (entry.getDatasetSequence() != null)
1282 transferAnnotation(entry.getDatasetSequence(), mp);
1285 // transfer any new features from entry onto sequence
1286 if (entry.getSequenceFeatures() != null)
1289 List<SequenceFeature> sfs = entry.getSequenceFeatures();
1290 for (SequenceFeature feature : sfs)
1292 SequenceFeature sf[] = (mp != null) ? mp.locateFeature(feature)
1293 : new SequenceFeature[] { new SequenceFeature(feature) };
1296 for (int sfi = 0; sfi < sf.length; sfi++)
1298 addSequenceFeature(sf[sfi]);
1304 // transfer PDB entries
1305 if (entry.getAllPDBEntries() != null)
1307 Enumeration<PDBEntry> e = entry.getAllPDBEntries().elements();
1308 while (e.hasMoreElements())
1310 PDBEntry pdb = e.nextElement();
1314 // transfer database references
1315 DBRefEntry[] entryRefs = entry.getDBRefs();
1316 if (entryRefs != null)
1318 for (int r = 0; r < entryRefs.length; r++)
1320 DBRefEntry newref = new DBRefEntry(entryRefs[r]);
1321 if (newref.getMap() != null && mp != null)
1323 // remap ref using our local mapping
1325 // we also assume all version string setting is done by dbSourceProxy
1327 * if (!newref.getSource().equalsIgnoreCase(dbSource)) {
1328 * newref.setSource(dbSource); }
1336 * @return The index (zero-based) on this sequence in the MSA. It returns
1337 * {@code -1} if this information is not available.
1340 public int getIndex()
1346 * Defines the position of this sequence in the MSA. Use the value {@code -1}
1347 * if this information is undefined.
1350 * position for this sequence. This value is zero-based (zero for
1351 * this first sequence)
1354 public void setIndex(int value)
1360 public void setRNA(RNA r)
1372 public List<AlignmentAnnotation> getAlignmentAnnotations(String calcId,
1375 List<AlignmentAnnotation> result = new ArrayList<AlignmentAnnotation>();
1376 if (this.annotation != null)
1378 for (AlignmentAnnotation ann : annotation)
1380 if (ann.calcId != null && ann.calcId.equals(calcId)
1381 && ann.label != null && ann.label.equals(label))
1391 public String toString()
1393 return getDisplayId(false);
1397 public PDBEntry getPDBEntry(String pdbIdStr)
1399 if (getDatasetSequence() != null)
1401 return getDatasetSequence().getPDBEntry(pdbIdStr);
1407 List<PDBEntry> entries = getAllPDBEntries();
1408 for (PDBEntry entry : entries)
1410 if (entry.getId().equalsIgnoreCase(pdbIdStr))
1419 public List<DBRefEntry> getPrimaryDBRefs()
1421 if (datasetSequence != null)
1423 return datasetSequence.getPrimaryDBRefs();
1425 if (dbrefs == null || dbrefs.length == 0)
1427 return Collections.emptyList();
1429 synchronized (dbrefs)
1431 List<DBRefEntry> primaries = new ArrayList<DBRefEntry>();
1432 DBRefEntry[] tmp = new DBRefEntry[1];
1433 for (DBRefEntry ref : dbrefs)
1435 if (!ref.isPrimaryCandidate())
1441 MapList mp = ref.getMap().getMap();
1442 if (mp.getFromLowest() > start || mp.getFromHighest() < end)
1444 // map only involves a subsequence, so cannot be primary
1448 // whilst it looks like it is a primary ref, we also sanity check type
1449 if (DBRefUtils.getCanonicalName(DBRefSource.PDB).equals(
1450 DBRefUtils.getCanonicalName(ref.getSource())))
1452 // PDB dbrefs imply there should be a PDBEntry associated
1453 // TODO: tighten PDB dbrefs
1454 // formally imply Jalview has actually downloaded and
1455 // parsed the pdb file. That means there should be a cached file
1456 // handle on the PDBEntry, and a real mapping between sequence and
1457 // extracted sequence from PDB file
1458 PDBEntry pdbentry = getPDBEntry(ref.getAccessionId());
1459 if (pdbentry != null && pdbentry.getFile() != null)
1465 // check standard protein or dna sources
1467 DBRefEntry[] res = DBRefUtils.selectDbRefs(!isProtein(), tmp);
1468 if (res != null && res[0] == tmp[0])
1482 public List<SequenceFeature> findFeatures(int fromColumn, int toColumn,
1485 int startPos = findPosition(fromColumn - 1); // convert base 1 to base 0
1486 int endPos = findPosition(toColumn - 1);
1488 List<SequenceFeature> result = new ArrayList<>();
1489 if (datasetSequence != null)
1491 result = datasetSequence.getFeatures().findFeatures(startPos, endPos,
1496 result = sequenceFeatureStore.findFeatures(startPos, endPos, types);
1500 * if the start or end column is gapped, startPos or endPos may be to the
1501 * left or right, and we may have included adjacent or enclosing features;
1502 * remove any that are not enclosing, non-contact features
1504 if (endPos > this.end || Comparison.isGap(sequence[fromColumn - 1])
1505 || Comparison.isGap(sequence[toColumn - 1]))
1507 ListIterator<SequenceFeature> it = result.listIterator();
1508 while (it.hasNext())
1510 SequenceFeature sf = it.next();
1511 int featureStartColumn = findIndex(sf.getBegin());
1512 int featureEndColumn = findIndex(sf.getEnd());
1513 boolean noOverlap = featureStartColumn > toColumn
1514 || featureEndColumn < fromColumn;
1517 * reject an 'enclosing' feature if it is actually a contact feature
1519 if (sf.isContactFeature() && featureStartColumn < fromColumn
1520 && featureEndColumn > toColumn)