/*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b1)
+ * Copyright (C) 2015 The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.datamodel;
+import jalview.analysis.AlignSeq;
+import jalview.util.StringUtils;
+
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import fr.orsay.lri.varna.models.rna.RNA;
-import jalview.analysis.AlignSeq;
-import jalview.util.StringUtils;
-
/**
*
* Implements the SequenceI interface for a char[] based sequence object.
* @author $author$
* @version $Revision$
*/
-public class Sequence implements SequenceI
+public class Sequence extends ASequence implements SequenceI
{
SequenceI datasetSequence;
RNA rna;
- private boolean hidden;
-
/**
* This annotation is displayed below the alignment but the positions are tied
* to the residues of this sequence
*/
public Sequence(String name, String sequence, int start, int end)
{
- this.name = name;
- this.sequence = sequence.toCharArray();
- this.start = start;
- this.end = end;
- parseId();
- checkValidRange();
+ initSeqAndName(name, sequence.toCharArray(), start, end);
}
public Sequence(String name, char[] sequence, int start, int end)
{
- this.name = name;
- this.sequence = sequence;
- this.start = start;
- this.end = end;
+ initSeqAndName(name, sequence, start, end);
+ }
+
+ /**
+ * Stage 1 constructor - assign name, sequence, and set start and end fields.
+ * start and end are updated values from name2 if it ends with /start-end
+ *
+ * @param name2
+ * @param sequence2
+ * @param start2
+ * @param end2
+ */
+ protected void initSeqAndName(String name2, char[] sequence2, int start2,
+ int end2)
+ {
+ this.name = name2;
+ this.sequence = sequence2;
+ this.start = start2;
+ this.end = end2;
parseId();
checkValidRange();
}
*/
public Sequence(SequenceI seq, AlignmentAnnotation[] alAnnotation)
{
- this(seq.getName(), seq.getSequence(), seq.getStart(), seq.getEnd());
+ initSeqFrom(seq, alAnnotation);
+
+ }
+
+ protected void initSeqFrom(SequenceI seq,
+ AlignmentAnnotation[] alAnnotation)
+ {
+ initSeqAndName(seq.getName(), seq.getSequence(), seq.getStart(),
+ seq.getEnd());
description = seq.getDescription();
if (seq.getSequenceFeatures() != null)
{
}
}
}
- if (seq.getPDBId() != null)
+ if (seq.getAllPDBEntries() != null)
{
- Vector ids = seq.getPDBId();
+ Vector ids = seq.getAllPDBEntries();
Enumeration e = ids.elements();
while (e.hasMoreElements())
{
* @return DOCUMENT ME!
*/
@Override
- public Vector<PDBEntry> getPDBId()
+ public Vector<PDBEntry> getAllPDBEntries()
{
return pdbIds;
}
{
if (lastj != -1)
{
- map.add(new int[]
- { lastj, j - 1 });
+ map.add(new int[] { lastj, j - 1 });
lastj = -1;
}
}
}
if (lastj != -1)
{
- map.add(new int[]
- { lastj, j - 1 });
+ map.add(new int[] { lastj, j - 1 });
lastj = -1;
}
return map;
public void deleteChars(int i, int j)
{
int newstart = start, newend = end;
- if (i >= sequence.length)
+ if (i >= sequence.length || i < 0)
{
return;
}
.toArray(new AlignmentAnnotation[annotation.size()]);
}
-
@Override
public boolean hasAnnotation(AlignmentAnnotation ann)
{
// move database references onto dataset sequence
datasetSequence.setDBRef(getDBRef());
setDBRef(null);
- datasetSequence.setPDBId(getPDBId());
+ datasetSequence.setPDBId(getAllPDBEntries());
setPDBId(null);
datasetSequence.updatePDBIds();
if (annotation != null)
for (int si = 0; si < sfs.length; si++)
{
SequenceFeature sf[] = (mp != null) ? mp.locateFeature(sfs[si])
- : new SequenceFeature[]
- { new SequenceFeature(sfs[si]) };
+ : new SequenceFeature[] { new SequenceFeature(sfs[si]) };
if (sf != null && sf.length > 0)
{
for (int sfi = 0; sfi < sf.length; sfi++)
}
// transfer PDB entries
- if (entry.getPDBId() != null)
+ if (entry.getAllPDBEntries() != null)
{
- Enumeration e = entry.getPDBId().elements();
+ Enumeration e = entry.getAllPDBEntries().elements();
while (e.hasMoreElements())
{
PDBEntry pdb = (PDBEntry) e.nextElement();
return result;
}
- @Override
- public boolean isHidden()
+ public String toString()
{
- return this.hidden;
+ return getDisplayId(false);
}
@Override
- public void setHidden(Boolean hidden)
+ public PDBEntry getPDBEntry(String pdbIdStr)
{
- this.hidden = hidden;
+ if (getDatasetSequence() == null
+ || getDatasetSequence().getAllPDBEntries() == null)
+ {
+ return null;
+ }
+ List<PDBEntry> entries = getDatasetSequence().getAllPDBEntries();
+ for (PDBEntry entry : entries)
+ {
+ if (entry.getId().equalsIgnoreCase(pdbIdStr))
+ {
+ return entry;
+ }
+ }
+ return null;
}
}