}
/**
- * copy over the RESNUM seqfeatures from the internal chain sequence to the
+ * Copies over the RESNUM seqfeatures from the internal chain sequence to the
* mapped sequence
*
* @param seq
* @param status
* The Status of the transferred annotation
- * @return the features added to sq (or its dataset)
*/
- public SequenceFeature[] transferRESNUMFeatures(SequenceI seq,
+ public void transferRESNUMFeatures(SequenceI seq,
String status)
{
SequenceI sq = seq;
sq = sq.getDatasetSequence();
if (sq == sequence)
{
- return null;
+ return;
}
}
- /**
+
+ /*
* Remove any existing features for this chain if they exist ?
* SequenceFeature[] seqsfeatures=seq.getSequenceFeatures(); int
* totfeat=seqsfeatures.length; // Remove any features for this exact chain
{
status = PDBChain.IEASTATUS;
}
- SequenceFeature[] features = sequence.getSequenceFeatures();
- if (features == null)
- {
- return null;
- }
- for (int i = 0; i < features.length; i++)
+
+ List<SequenceFeature> features = sequence.getSequenceFeatures();
+ for (SequenceFeature feature : features)
{
- SequenceFeature feature = features[i];
if (feature.getFeatureGroup() != null
&& feature.getFeatureGroup().equals(pdbid))
{
}
}
}
- return features;
}
/**
* duplication (e.g. same variation from two
* transcripts)
*/
- SequenceFeature[] sfs = ms.getSequenceFeatures();
- if (sfs != null)
+ List<SequenceFeature> sfs = ms.getFeatures()
+ .getAllFeatures();
+ for (SequenceFeature feat : sfs)
{
- for (SequenceFeature feat : sfs)
+ /*
+ * make a flyweight feature object which ignores Parent
+ * attribute in equality test; this avoids creating many
+ * otherwise duplicate exon features on genomic sequence
+ */
+ SequenceFeature newFeature = new SequenceFeature(feat)
{
- /*
- * make a flyweight feature object which ignores Parent
- * attribute in equality test; this avoids creating many
- * otherwise duplicate exon features on genomic sequence
- */
- SequenceFeature newFeature = new SequenceFeature(feat)
+ @Override
+ public boolean equals(Object o)
{
- @Override
- public boolean equals(Object o)
- {
- return super.equals(o, true);
- }
- };
- matched.addSequenceFeature(newFeature);
- }
+ return super.equals(o, true);
+ }
+ };
+ matched.addSequenceFeature(newFeature);
}
-
}
cf.addMap(retrievedSequence, map.getTo(), map.getMap());
} catch (Exception e)
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
-import java.util.Map;
public class Dna
{
*/
MapList map = new MapList(scontigs, new int[] { 1, resSize }, 3, 1);
- transferCodedFeatures(selection, newseq, map, null, null);
+ transferCodedFeatures(selection, newseq, map);
/*
* Construct a dataset sequence for our new peptide.
/**
* Given a peptide newly translated from a dna sequence, copy over and set any
- * features on the peptide from the DNA. If featureTypes is null, all features
- * on the dna sequence are searched (rather than just the displayed ones), and
- * similarly for featureGroups.
+ * features on the peptide from the DNA.
*
* @param dna
* @param pep
* @param map
- * @param featureTypes
- * hash whose keys are the displayed feature type strings
- * @param featureGroups
- * hash where keys are feature groups and values are Boolean objects
- * indicating if they are displayed.
*/
private static void transferCodedFeatures(SequenceI dna, SequenceI pep,
- MapList map, Map<String, Object> featureTypes,
- Map<String, Boolean> featureGroups)
+ MapList map)
{
- SequenceFeature[] sfs = dna.getSequenceFeatures();
- Boolean fgstate;
DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(),
DBRefSource.DNACODINGDBS);
if (dnarefs != null)
}
}
}
- if (sfs != null)
+ for (SequenceFeature sf : dna.getFeatures().getAllFeatures())
{
- for (SequenceFeature sf : sfs)
- {
- fgstate = (featureGroups == null) ? null : featureGroups
- .get(sf.featureGroup);
- if ((featureTypes == null || featureTypes.containsKey(sf.getType()))
- && (fgstate == null || fgstate.booleanValue()))
+ if (FeatureProperties.isCodingFeature(null, sf.getType()))
{
- if (FeatureProperties.isCodingFeature(null, sf.getType()))
+ // if (map.intersectsFrom(sf[f].begin, sf[f].end))
{
- // if (map.intersectsFrom(sf[f].begin, sf[f].end))
- {
- }
}
}
- }
}
}
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import java.util.Vector;
public class SeqsetUtils
{
sqinfo.put("Description", seq.getDescription());
}
- Vector sfeat = new Vector();
- jalview.datamodel.SequenceFeature[] sfarray = seq.getSequenceFeatures();
- if (sfarray != null && sfarray.length > 0)
- {
- for (int i = 0; i < sfarray.length; i++)
- {
- sfeat.addElement(sfarray[i]);
- }
- }
+
+ Vector<SequenceFeature> sfeat = new Vector<SequenceFeature>();
+ List<SequenceFeature> sfs = seq.getFeatures().getAllFeatures();
+ sfeat.addAll(sfs);
+
if (seq.getDatasetSequence() == null)
{
sqinfo.put("SeqFeatures", sfeat);
String oldname = (String) sqinfo.get("Name");
Integer start = (Integer) sqinfo.get("Start");
Integer end = (Integer) sqinfo.get("End");
- Vector sfeatures = (Vector) sqinfo.get("SeqFeatures");
+ Vector<SequenceFeature> sfeatures = (Vector<SequenceFeature>) sqinfo
+ .get("SeqFeatures");
Vector<PDBEntry> pdbid = (Vector<PDBEntry>) sqinfo.get("PdbId");
String description = (String) sqinfo.get("Description");
Sequence seqds = (Sequence) sqinfo.get("datasetSequence");
sq.setEnd(end.intValue());
}
- if ((sfeatures != null) && (sfeatures.size() > 0))
+ if (sfeatures != null && !sfeatures.isEmpty())
{
- SequenceFeature[] sfarray = new SequenceFeature[sfeatures.size()];
- for (int is = 0, isize = sfeatures.size(); is < isize; is++)
- {
- sfarray[is] = (SequenceFeature) sfeatures.elementAt(is);
- }
- sq.setSequenceFeatures(sfarray);
+ sq.setSequenceFeatures(sfeatures);
}
if (description != null)
{
{
}
- public EditCommand(String description)
+ public EditCommand(String desc)
{
- this.description = description;
+ this.description = desc;
}
- public EditCommand(String description, Action command, SequenceI[] seqs,
+ public EditCommand(String desc, Action command, SequenceI[] seqs,
int position, int number, AlignmentI al)
{
- this.description = description;
+ this.description = desc;
if (command == Action.CUT || command == Action.PASTE)
{
setEdit(new Edit(command, seqs, position, number, al));
performEdit(0, null);
}
- public EditCommand(String description, Action command, String replace,
+ public EditCommand(String desc, Action command, String replace,
SequenceI[] seqs, int position, int number, AlignmentI al)
{
- this.description = description;
+ this.description = desc;
if (command == Action.REPLACE)
{
setEdit(new Edit(command, seqs, position, number, al, replace));
{
// modify the oldds if necessary
if (oldds != sequence.getDatasetSequence()
- || sequence.getSequenceFeatures() != null)
+ || sequence.getFeatures().hasFeatures())
{
if (command.oldds == null)
{
return;
}
- SequenceFeature[] oldsf = new SequenceFeature[sf.size()];
+ List<SequenceFeature> oldsf = new ArrayList<SequenceFeature>();
int cSize = j - i;
- int s = 0;
for (SequenceFeature feature : sf)
{
SequenceFeature copy = new SequenceFeature(feature);
- oldsf[s++] = copy;
+ oldsf.add(copy);
if (feature.getEnd() < i)
{
if (command.editedFeatures == null)
{
- command.editedFeatures = new Hashtable<SequenceI, SequenceFeature[]>();
+ command.editedFeatures = new Hashtable<SequenceI, List<SequenceFeature>>();
}
command.editedFeatures.put(seq, oldsf);
Hashtable<String, Annotation[]> deletedAnnotations;
- Hashtable<SequenceI, SequenceFeature[]> editedFeatures;
+ Hashtable<SequenceI, List<SequenceFeature>> editedFeatures;
AlignmentI al;
char gapChar;
- public Edit(Action command, SequenceI[] seqs, int position, int number,
- char gapChar)
+ public Edit(Action cmd, SequenceI[] sqs, int pos, int count,
+ char gap)
{
- this.command = command;
- this.seqs = seqs;
- this.position = position;
- this.number = number;
- this.gapChar = gapChar;
+ this.command = cmd;
+ this.seqs = sqs;
+ this.position = pos;
+ this.number = count;
+ this.gapChar = gap;
}
- Edit(Action command, SequenceI[] seqs, int position, int number,
- AlignmentI al)
+ Edit(Action cmd, SequenceI[] sqs, int pos, int count,
+ AlignmentI align)
{
- this.gapChar = al.getGapCharacter();
- this.command = command;
- this.seqs = seqs;
- this.position = position;
- this.number = number;
- this.al = al;
-
- alIndex = new int[seqs.length];
- for (int i = 0; i < seqs.length; i++)
+ this.gapChar = align.getGapCharacter();
+ this.command = cmd;
+ this.seqs = sqs;
+ this.position = pos;
+ this.number = count;
+ this.al = align;
+
+ alIndex = new int[sqs.length];
+ for (int i = 0; i < sqs.length; i++)
{
- alIndex[i] = al.findIndex(seqs[i]);
+ alIndex[i] = align.findIndex(sqs[i]);
}
- fullAlignmentHeight = (al.getHeight() == seqs.length);
+ fullAlignmentHeight = (align.getHeight() == sqs.length);
}
- Edit(Action command, SequenceI[] seqs, int position, int number,
- AlignmentI al, String replace)
+ Edit(Action cmd, SequenceI[] sqs, int pos, int count,
+ AlignmentI align, String replace)
{
- this.command = command;
- this.seqs = seqs;
- this.position = position;
- this.number = number;
- this.al = al;
- this.gapChar = al.getGapCharacter();
- string = new char[seqs.length][];
- for (int i = 0; i < seqs.length; i++)
+ this.command = cmd;
+ this.seqs = sqs;
+ this.position = pos;
+ this.number = count;
+ this.al = align;
+ this.gapChar = align.getGapCharacter();
+ string = new char[sqs.length][];
+ for (int i = 0; i < sqs.length; i++)
{
string[i] = replace.toCharArray();
}
- fullAlignmentHeight = (al.getHeight() == seqs.length);
+ fullAlignmentHeight = (align.getHeight() == sqs.length);
}
public SequenceI[] getSequences()
*/
int index = -1;
- /** array of sequence features - may not be null for a valid sequence object */
- public SequenceFeature[] sequenceFeatures;
-
private SequenceFeatures sequenceFeatureStore;
/**
*/
public Sequence(String name, String sequence, int start, int end)
{
+ this();
initSeqAndName(name, sequence.toCharArray(), start, end);
}
public Sequence(String name, char[] sequence, int start, int end)
{
+ this();
initSeqAndName(name, sequence, start, end);
}
this.sequence = sequence2;
this.start = start2;
this.end = end2;
- sequenceFeatureStore = new SequenceFeatures();
parseId();
checkValidRange();
}
}
/**
+ * default constructor
+ */
+ private Sequence()
+ {
+ sequenceFeatureStore = new SequenceFeatures();
+ }
+
+ /**
* Creates a new Sequence object.
*
* @param name
*/
public Sequence(SequenceI seq, AlignmentAnnotation[] alAnnotation)
{
+ this();
initSeqFrom(seq, alAnnotation);
-
}
/**
addDBRef(new DBRefEntry(dbr[i]));
}
}
- if (seq.getSequenceFeatures() != null)
+
+ /*
+ * make copies of any sequence features
+ */
+ for (SequenceFeature sf : seq.getSequenceFeatures())
{
- SequenceFeature[] sf = seq.getSequenceFeatures();
- for (int i = 0; i < sf.length; i++)
- {
- addSequenceFeature(new SequenceFeature(sf[i]));
- }
+ addSequenceFeature(new SequenceFeature(sf));
}
}
}
@Override
- public void setSequenceFeatures(SequenceFeature[] features)
+ public void setSequenceFeatures(List<SequenceFeature> features)
{
- if (datasetSequence == null)
- {
- sequenceFeatures = features;
- }
- else
+ if (datasetSequence != null)
{
- if (datasetSequence.getSequenceFeatures() != features
- && datasetSequence.getSequenceFeatures() != null
- && datasetSequence.getSequenceFeatures().length > 0)
- {
- new Exception(
- "Warning: JAL-2046 side effect ? Possible implementation error: overwriting dataset sequence features by setting sequence features on alignment")
- .printStackTrace();
- }
datasetSequence.setSequenceFeatures(features);
+ return;
}
+ sequenceFeatureStore = new SequenceFeatures(features);
}
@Override
return false;
}
- if (sequenceFeatures == null && datasetSequence != null)
+ if (datasetSequence != null)
{
return datasetSequence.addSequenceFeature(sf);
}
- if (sequenceFeatures == null)
- {
- sequenceFeatures = new SequenceFeature[0];
- }
-
- for (int i = 0; i < sequenceFeatures.length; i++)
- {
- if (sequenceFeatures[i].equals(sf))
- {
- return false;
- }
- }
-
- SequenceFeature[] temp = new SequenceFeature[sequenceFeatures.length + 1];
- System.arraycopy(sequenceFeatures, 0, temp, 0, sequenceFeatures.length);
- temp[sequenceFeatures.length] = sf;
- sequenceFeatures = temp;
-
- sequenceFeatureStore.add(sf);
- return true;
+ return sequenceFeatureStore.add(sf);
}
@Override
public void deleteFeature(SequenceFeature sf)
{
- if (sequenceFeatures == null)
- {
- if (datasetSequence != null)
- {
- datasetSequence.deleteFeature(sf);
- }
- return;
- }
-
- /*
- * new way
- */
- sequenceFeatureStore.delete(sf);
-
- /*
- * old way - to be removed
- */
- int index = 0;
- for (index = 0; index < sequenceFeatures.length; index++)
- {
- if (sequenceFeatures[index].equals(sf))
- {
- break;
- }
- }
-
- if (index == sequenceFeatures.length)
- {
- return;
- }
-
- int sfLength = sequenceFeatures.length;
- if (sfLength < 2)
+ if (datasetSequence != null)
{
- sequenceFeatures = null;
+ datasetSequence.deleteFeature(sf);
}
else
{
- SequenceFeature[] temp = new SequenceFeature[sfLength - 1];
- System.arraycopy(sequenceFeatures, 0, temp, 0, index);
-
- if (index < sfLength)
- {
- System.arraycopy(sequenceFeatures, index + 1, temp, index,
- sequenceFeatures.length - index - 1);
- }
-
- sequenceFeatures = temp;
+ sequenceFeatureStore.delete(sf);
}
}
/**
- * Returns the sequence features (if any), looking first on the sequence, then
- * on its dataset sequence, and so on until a non-null value is found (or
- * none). This supports retrieval of sequence features stored on the sequence
- * (as in the applet) or on the dataset sequence (as in the Desktop version).
+ * {@inheritDoc}
*
* @return
*/
@Override
- public SequenceFeature[] getSequenceFeatures()
+ public List<SequenceFeature> getSequenceFeatures()
{
- SequenceFeature[] features = sequenceFeatures;
-
- SequenceI seq = this;
- int count = 0; // failsafe against loop in sequence.datasetsequence...
- while (features == null && seq.getDatasetSequence() != null
- && count++ < 10)
+ if (datasetSequence != null)
{
- seq = seq.getDatasetSequence();
- features = ((Sequence) seq).sequenceFeatures;
+ return datasetSequence.getSequenceFeatures();
}
- return features;
+ return sequenceFeatureStore.getAllFeatures();
}
@Override
dsseq.setDescription(description);
// move features and database references onto dataset sequence
- dsseq.sequenceFeatures = sequenceFeatures;
- sequenceFeatures = null;
dsseq.sequenceFeatureStore = sequenceFeatureStore;
sequenceFeatureStore = null;
dsseq.dbrefs = dbrefs;
if (entry.getSequenceFeatures() != null)
{
- SequenceFeature[] sfs = entry.getSequenceFeatures();
- for (int si = 0; si < sfs.length; si++)
+ List<SequenceFeature> sfs = entry.getSequenceFeatures();
+ for (SequenceFeature feature : sfs)
{
- SequenceFeature sf[] = (mp != null) ? mp.locateFeature(sfs[si])
- : new SequenceFeature[] { new SequenceFeature(sfs[si]) };
- if (sf != null && sf.length > 0)
+ SequenceFeature sf[] = (mp != null) ? mp.locateFeature(feature)
+ : new SequenceFeature[] { new SequenceFeature(feature) };
+ if (sf != null)
{
for (int sfi = 0; sfi < sf.length; sfi++)
{
public void insertCharAt(int position, int count, char ch);
/**
- * Gets array holding sequence features associated with this sequence. The
- * array may be held by the sequence's dataset sequence if that is defined.
+ * Answers a list of all sequence features associated with this sequence. The
+ * list may be held by the sequence's dataset sequence if that is defined.
*
* @return hard reference to array
*/
- public SequenceFeature[] getSequenceFeatures();
+ public List<SequenceFeature> getSequenceFeatures();
/**
* Answers the object holding features for the sequence
SequenceFeaturesI getFeatures();
/**
- * Replaces the array of sequence features associated with this sequence with
- * a new array reference. If this sequence has a dataset sequence, then this
- * method will update the dataset sequence's feature array
+ * Replaces the sequence features associated with this sequence with the given
+ * features. If this sequence has a dataset sequence, then this method will
+ * update the dataset sequence's features instead.
*
* @param features
- * New array of sequence features
*/
- public void setSequenceFeatures(SequenceFeature[] features);
+ public void setSequenceFeatures(List<SequenceFeature> features);
/**
* DOCUMENT ME!
{
/*
* use a TreeMap so that features are returned in alphabetical order of type
- * wrap as a synchronized map for add and delete operations
+ * ? wrap as a synchronized map for add and delete operations
*/
// featureStore = Collections
// .synchronizedSortedMap(new TreeMap<String, FeatureStore>());
}
/**
+ * Constructor given a list of features
+ */
+ public SequenceFeatures(List<SequenceFeature> features)
+ {
+ this();
+ if (features != null)
+ {
+ for (SequenceFeature feature : features)
+ {
+ add(feature);
+ }
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
// TODO: omit sequence features from each alignment view's XML dump if we
// are storing dataset
- if (jds.getSequenceFeatures() != null)
+ List<jalview.datamodel.SequenceFeature> sfs = jds
+ .getSequenceFeatures();
+ for (SequenceFeature sf : sfs)
{
- jalview.datamodel.SequenceFeature[] sf = jds.getSequenceFeatures();
- int index = 0;
- while (index < sf.length)
- {
- Features features = new Features();
+ Features features = new Features();
- features.setBegin(sf[index].getBegin());
- features.setEnd(sf[index].getEnd());
- features.setDescription(sf[index].getDescription());
- features.setType(sf[index].getType());
- features.setFeatureGroup(sf[index].getFeatureGroup());
- features.setScore(sf[index].getScore());
- if (sf[index].links != null)
+ features.setBegin(sf.getBegin());
+ features.setEnd(sf.getEnd());
+ features.setDescription(sf.getDescription());
+ features.setType(sf.getType());
+ features.setFeatureGroup(sf.getFeatureGroup());
+ features.setScore(sf.getScore());
+ if (sf.links != null)
+ {
+ for (int l = 0; l < sf.links.size(); l++)
{
- for (int l = 0; l < sf[index].links.size(); l++)
- {
- OtherData keyValue = new OtherData();
- keyValue.setKey("LINK_" + l);
- keyValue.setValue(sf[index].links.elementAt(l).toString());
- features.addOtherData(keyValue);
- }
+ OtherData keyValue = new OtherData();
+ keyValue.setKey("LINK_" + l);
+ keyValue.setValue(sf.links.elementAt(l).toString());
+ features.addOtherData(keyValue);
}
- if (sf[index].otherDetails != null)
+ }
+ if (sf.otherDetails != null)
+ {
+ String key;
+ Iterator<String> keys = sf.otherDetails.keySet().iterator();
+ while (keys.hasNext())
{
- String key;
- Iterator<String> keys = sf[index].otherDetails.keySet()
- .iterator();
- while (keys.hasNext())
- {
- key = keys.next();
- OtherData keyValue = new OtherData();
- keyValue.setKey(key);
- keyValue.setValue(sf[index].otherDetails.get(key).toString());
- features.addOtherData(keyValue);
- }
+ key = keys.next();
+ OtherData keyValue = new OtherData();
+ keyValue.setKey(key);
+ keyValue.setValue(sf.otherDetails.get(key).toString());
+ features.addOtherData(keyValue);
}
-
- jseq.addFeatures(features);
- index++;
}
+
+ jseq.addFeatures(features);
}
if (jdatasq.getAllPDBEntries() != null)
*/
public class StockholmFile extends AlignFile
{
+ private static final String ANNOTATION = "annotation";
+
private static final Regex OPEN_PAREN = new Regex("(<|\\[)", "(");
private static final Regex CLOSE_PAREN = new Regex("(>|\\])", ")");
while (j.hasMoreElements())
{
String desc = j.nextElement().toString();
- if ("annotations".equals(desc) && annotsAdded)
+ if (ANNOTATION.equals(desc) && annotsAdded)
{
// don't add features if we already added an annotation row
continue;
content = new Hashtable();
features.put(this.id2type(type), content);
}
- String ns = (String) content.get("annotation");
+ String ns = (String) content.get(ANNOTATION);
if (ns == null)
{
}
// finally, append the annotation line
ns += seq;
- content.put("annotation", ns);
+ content.put(ANNOTATION, ns);
// // end of wrapped annotation block.
// // Now a new row is created with the current set of data
package jalview.io.vamsas;
import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.io.VamsasAppDatastore;
+import java.util.List;
+
import uk.ac.vamsas.objects.core.DataSet;
import uk.ac.vamsas.objects.core.DbRef;
import uk.ac.vamsas.objects.core.Sequence;
doJvUpdate();
}
+ @Override
public void addFromDocument()
{
Sequence vseq = (Sequence) vobj;
modified = true;
}
+ @Override
public void updateFromDoc()
{
Sequence sq = (Sequence) vobj;
*/
private boolean updateSqFeatures()
{
- boolean modified = false;
+ boolean changed = false;
SequenceI sq = (SequenceI) jvobj;
// add or update any new features/references on dataset sequence
- if (sq.getSequenceFeatures() != null)
+ List<SequenceFeature> sfs = sq.getSequenceFeatures();
+ for (SequenceFeature sf : sfs)
{
- int sfSize = sq.getSequenceFeatures().length;
-
- for (int sf = 0; sf < sfSize; sf++)
- {
- modified |= new jalview.io.vamsas.Sequencefeature(datastore,
- (jalview.datamodel.SequenceFeature) sq
- .getSequenceFeatures()[sf], dataset,
- (Sequence) vobj).docWasUpdated();
- }
+ changed |= new jalview.io.vamsas.Sequencefeature(datastore, sf,
+ dataset, (Sequence) vobj).docWasUpdated();
}
- return modified;
+
+ return changed;
}
+ @Override
public void addToDocument()
{
SequenceI sq = (SequenceI) jvobj;
return modifiedtheseq;
}
+ @Override
public void conflict()
{
log.warn("Conflict in dataset sequence update to document. Overwriting document");
boolean modified = false;
+ @Override
public void updateToDoc()
{
SequenceI sq = (SequenceI) jvobj;
import jalview.structure.StructureImportSettings;
import java.awt.Color;
+import java.util.List;
import java.util.Vector;
import org.testng.annotations.BeforeClass;
/*
* check sequence features
*/
- SequenceFeature[] sfs = c.sequence.getSequenceFeatures();
- assertEquals(3, sfs.length);
- assertEquals("RESNUM", sfs[0].type);
- assertEquals("MET:4 1gaqA", sfs[0].description);
- assertEquals(4, sfs[0].begin);
- assertEquals(4, sfs[0].end);
- assertEquals("RESNUM", sfs[0].type);
- assertEquals("LYS:5 1gaqA", sfs[1].description);
- assertEquals(5, sfs[1].begin);
- assertEquals(5, sfs[1].end);
- assertEquals("LEU:6 1gaqA", sfs[2].description);
- assertEquals(6, sfs[2].begin);
- assertEquals(6, sfs[2].end);
+ List<SequenceFeature> sfs = c.sequence.getSequenceFeatures();
+ assertEquals(3, sfs.size());
+ assertEquals("RESNUM", sfs.get(0).type);
+ assertEquals("MET:4 1gaqA", sfs.get(0).description);
+ assertEquals(4, sfs.get(0).begin);
+ assertEquals(4, sfs.get(0).end);
+ assertEquals("RESNUM", sfs.get(0).type);
+ assertEquals("LYS:5 1gaqA", sfs.get(1).description);
+ assertEquals(5, sfs.get(1).begin);
+ assertEquals(5, sfs.get(1).end);
+ assertEquals("LEU:6 1gaqA", sfs.get(2).description);
+ assertEquals(6, sfs.get(2).begin);
+ assertEquals(6, sfs.get(2).end);
}
private Atom makeAtom(int resnum, String name, String resname)
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.features.SequenceFeatures;
import jalview.gui.JvOptionPane;
import jalview.io.AppletFormatAdapter;
import jalview.io.DataSourceType;
/*
* check cds2 acquired a variant feature in position 5
*/
- SequenceFeature[] sfs = cds2Dss.getSequenceFeatures();
+ List<SequenceFeature> sfs = cds2Dss.getSequenceFeatures();
assertNotNull(sfs);
- assertEquals(1, sfs.length);
- assertEquals("variant", sfs[0].type);
- assertEquals(5, sfs[0].begin);
- assertEquals(5, sfs[0].end);
+ assertEquals(1, sfs.size());
+ assertEquals("variant", sfs.get(0).type);
+ assertEquals(5, sfs.get(0).begin);
+ assertEquals(5, sfs.get(0).end);
}
/**
* that partially overlap 5' or 3' (start or end) of target sequence
*/
AlignmentUtils.transferFeatures(dna, cds, map, null);
- SequenceFeature[] sfs = cds.getSequenceFeatures();
- assertEquals(6, sfs.length);
+ List<SequenceFeature> sfs = cds.getSequenceFeatures();
+ assertEquals(6, sfs.size());
- SequenceFeature sf = sfs[0];
+ SequenceFeature sf = sfs.get(0);
assertEquals("type2", sf.getType());
assertEquals("desc2", sf.getDescription());
assertEquals(2f, sf.getScore());
assertEquals(1, sf.getBegin());
assertEquals(1, sf.getEnd());
- sf = sfs[1];
+ sf = sfs.get(1);
assertEquals("type3", sf.getType());
assertEquals("desc3", sf.getDescription());
assertEquals(3f, sf.getScore());
assertEquals(1, sf.getBegin());
assertEquals(3, sf.getEnd());
- sf = sfs[2];
+ sf = sfs.get(2);
assertEquals("type4", sf.getType());
assertEquals(2, sf.getBegin());
assertEquals(5, sf.getEnd());
- sf = sfs[3];
+ sf = sfs.get(3);
assertEquals("type5", sf.getType());
assertEquals(1, sf.getBegin());
assertEquals(6, sf.getEnd());
- sf = sfs[4];
+ sf = sfs.get(4);
assertEquals("type8", sf.getType());
assertEquals(6, sf.getBegin());
assertEquals(6, sf.getEnd());
- sf = sfs[5];
+ sf = sfs.get(5);
assertEquals("type9", sf.getType());
assertEquals(6, sf.getBegin());
assertEquals(6, sf.getEnd());
// desc4 and desc8 are the 'omit these' varargs
AlignmentUtils.transferFeatures(dna, cds, map, null, "type4", "type8");
- SequenceFeature[] sfs = cds.getSequenceFeatures();
- assertEquals(1, sfs.length);
+ List<SequenceFeature> sfs = cds.getSequenceFeatures();
+ assertEquals(1, sfs.size());
- SequenceFeature sf = sfs[0];
+ SequenceFeature sf = sfs.get(0);
assertEquals("type5", sf.getType());
assertEquals(1, sf.getBegin());
assertEquals(6, sf.getEnd());
// "type5" is the 'select this type' argument
AlignmentUtils.transferFeatures(dna, cds, map, "type5");
- SequenceFeature[] sfs = cds.getSequenceFeatures();
- assertEquals(1, sfs.length);
+ List<SequenceFeature> sfs = cds.getSequenceFeatures();
+ assertEquals(1, sfs.size());
- SequenceFeature sf = sfs[0];
+ SequenceFeature sf = sfs.get(0);
assertEquals("type5", sf.getType());
assertEquals(1, sf.getBegin());
assertEquals(6, sf.getEnd());
* var6 P -> H COSMIC
* var6 P -> R COSMIC
*/
- SequenceFeature[] sfs = peptide.getSequenceFeatures();
- assertEquals(5, sfs.length);
+ List<SequenceFeature> sfs = peptide.getSequenceFeatures();
+ SequenceFeatures.sortFeatures(sfs, true);
+ assertEquals(5, sfs.size());
- SequenceFeature sf = sfs[0];
+ /*
+ * features are sorted by start position ascending, but in no
+ * particular order where start positions match; asserts here
+ * simply match the data returned (the order is not important)
+ */
+ SequenceFeature sf = sfs.get(0);
assertEquals(1, sf.getBegin());
assertEquals(1, sf.getEnd());
- assertEquals("p.Lys1Glu", sf.getDescription());
- assertEquals("var1.125A>G", sf.getValue("ID"));
- assertNull(sf.getValue("clinical_significance"));
- assertEquals("ID=var1.125A>G", sf.getAttributes());
+ assertEquals("p.Lys1Asn", sf.getDescription());
+ assertEquals("var4", sf.getValue("ID"));
+ assertEquals("Benign", sf.getValue("clinical_significance"));
+ assertEquals("ID=var4;clinical_significance=Benign", sf.getAttributes());
assertEquals(1, sf.links.size());
- // link to variation is urlencoded
assertEquals(
- "p.Lys1Glu var1.125A>G|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var1.125A%3EG",
+ "p.Lys1Asn var4|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var4",
sf.links.get(0));
assertEquals(ensembl, sf.getFeatureGroup());
- sf = sfs[1];
+ sf = sfs.get(1);
assertEquals(1, sf.getBegin());
assertEquals(1, sf.getEnd());
assertEquals("p.Lys1Gln", sf.getDescription());
sf.links.get(0));
assertEquals(dbSnp, sf.getFeatureGroup());
- sf = sfs[2];
+ sf = sfs.get(2);
assertEquals(1, sf.getBegin());
assertEquals(1, sf.getEnd());
- assertEquals("p.Lys1Asn", sf.getDescription());
- assertEquals("var4", sf.getValue("ID"));
- assertEquals("Benign", sf.getValue("clinical_significance"));
- assertEquals("ID=var4;clinical_significance=Benign", sf.getAttributes());
+ assertEquals("p.Lys1Glu", sf.getDescription());
+ assertEquals("var1.125A>G", sf.getValue("ID"));
+ assertNull(sf.getValue("clinical_significance"));
+ assertEquals("ID=var1.125A>G", sf.getAttributes());
assertEquals(1, sf.links.size());
+ // link to variation is urlencoded
assertEquals(
- "p.Lys1Asn var4|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var4",
+ "p.Lys1Glu var1.125A>G|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var1.125A%3EG",
sf.links.get(0));
assertEquals(ensembl, sf.getFeatureGroup());
- // var5 generates two distinct protein variant features
- sf = sfs[3];
+ sf = sfs.get(3);
assertEquals(3, sf.getBegin());
assertEquals(3, sf.getEnd());
- assertEquals("p.Pro3His", sf.getDescription());
+ assertEquals("p.Pro3Arg", sf.getDescription());
assertEquals("var6", sf.getValue("ID"));
assertEquals("Good", sf.getValue("clinical_significance"));
assertEquals("ID=var6;clinical_significance=Good", sf.getAttributes());
assertEquals(1, sf.links.size());
assertEquals(
- "p.Pro3His var6|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var6",
+ "p.Pro3Arg var6|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var6",
sf.links.get(0));
assertEquals(cosmic, sf.getFeatureGroup());
- sf = sfs[4];
+ // var5 generates two distinct protein variant features
+ sf = sfs.get(4);
assertEquals(3, sf.getBegin());
assertEquals(3, sf.getEnd());
- assertEquals("p.Pro3Arg", sf.getDescription());
+ assertEquals("p.Pro3His", sf.getDescription());
assertEquals("var6", sf.getValue("ID"));
assertEquals("Good", sf.getValue("clinical_significance"));
assertEquals("ID=var6;clinical_significance=Good", sf.getAttributes());
assertEquals(1, sf.links.size());
assertEquals(
- "p.Pro3Arg var6|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var6",
+ "p.Pro3His var6|http://www.ensembl.org/Homo_sapiens/Variation/Summary?v=var6",
sf.links.get(0));
assertEquals(cosmic, sf.getFeatureGroup());
}
SequenceI[] sqset2 = new SequenceI[] {
new Sequence(sqset[0].getName(), sqset[0].getSequenceAsString()),
new Sequence(sqset[1].getName(), sqset[1].getSequenceAsString()) };
- Assert.assertTrue(sqset[0].getSequenceFeatures()[0] == sf1);
- Assert.assertEquals(sqset2[0].getSequenceFeatures(), null);
+ Assert.assertSame(sqset[0].getSequenceFeatures().get(0), sf1);
+ Assert.assertTrue(sqset2[0].getSequenceFeatures().isEmpty());
ds.getSequenceAt(0).addSequenceFeature(sf2);
- Assert.assertEquals(sqset[0].getSequenceFeatures().length, 2);
+ Assert.assertEquals(sqset[0].getSequenceFeatures().size(), 2);
SeqsetUtils.deuniquify(unq, sqset2);
// explicitly test that original sequence features still exist because they
// are on the shared dataset sequence
- Assert.assertEquals(sqset[0].getSequenceFeatures().length, 2);
- Assert.assertEquals(sqset2[0].getSequenceFeatures().length, 2);
- Assert.assertTrue(sqset[0].getSequenceFeatures()[0] == sqset2[0]
- .getSequenceFeatures()[0]);
- Assert.assertTrue(sqset[0].getSequenceFeatures()[1] == sqset2[0]
- .getSequenceFeatures()[1]);
+ Assert.assertEquals(sqset[0].getSequenceFeatures().size(), 2);
+ Assert.assertEquals(sqset2[0].getSequenceFeatures().size(), 2);
+ Assert.assertSame(sqset[0].getSequenceFeatures().get(0), sqset2[0]
+ .getSequenceFeatures().get(0));
+ Assert.assertSame(sqset[0].getSequenceFeatures().get(1), sqset2[0]
+ .getSequenceFeatures().get(1));
}
}
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.features.SequenceFeatures;
import jalview.gui.JvOptionPane;
-import java.util.Arrays;
-import java.util.Comparator;
+import java.util.List;
import java.util.Map;
import org.testng.Assert;
Edit ec = testee.new Edit(Action.CUT, seqs, 3, 4, al); // cols 3-6 base 0
EditCommand.cut(ec, new AlignmentI[] { al });
- SequenceFeature[] sfs = seq0.getSequenceFeatures();
- Arrays.sort(sfs, new Comparator<SequenceFeature>()
- {
- @Override
- public int compare(SequenceFeature o1, SequenceFeature o2)
- {
- return Integer.compare(o1.getBegin(), o2.getBegin());
- }
- });
- assertEquals(4, sfs.length); // feature internal to cut has been deleted
- SequenceFeature sf = sfs[0];
+ List<SequenceFeature> sfs = seq0.getSequenceFeatures();
+ SequenceFeatures.sortFeatures(sfs, true);
+
+ assertEquals(4, sfs.size()); // feature internal to cut has been deleted
+ SequenceFeature sf = sfs.get(0);
assertEquals("before", sf.getType());
assertEquals(1, sf.getBegin());
assertEquals(3, sf.getEnd());
- sf = sfs[1];
+ sf = sfs.get(1);
assertEquals("overlap left", sf.getType());
assertEquals(2, sf.getBegin());
assertEquals(3, sf.getEnd()); // truncated by cut
- sf = sfs[2];
+ sf = sfs.get(2);
assertEquals("overlap right", sf.getType());
assertEquals(4, sf.getBegin()); // shifted left by cut
assertEquals(5, sf.getEnd()); // truncated by cut
- sf = sfs[3];
+ sf = sfs.get(3);
assertEquals("after", sf.getType());
assertEquals(4, sf.getBegin()); // shifted left by cut
assertEquals(6, sf.getEnd()); // shifted left by cut
}
}
// sanity check
- SequenceFeature[] sfs = seq0.getSequenceFeatures();
- assertEquals(func(5), sfs.length);
+ List<SequenceFeature> sfs = seq0.getSequenceFeatures();
+ assertEquals(func(5), sfs.size());
/*
* now perform all possible cuts of subranges of 1-5 (followed by Undo)
else
{
assertEquals(msg + "wrong number of features left", func(5)
- - func(to - from + 1), sfs.length);
+ - func(to - from + 1), sfs.size());
}
/*
* undo ready for next cut
*/
testee.undoCommand(new AlignmentI[] { alignment });
- assertEquals(func(5), seq0.getSequenceFeatures().length);
+ assertEquals(func(5), seq0.getSequenceFeatures().size());
}
}
}
/*
* feature on CC(3-4) should now be on CC(1-2)
*/
- SequenceFeature[] sfs = seq0.getSequenceFeatures();
- assertEquals(1, sfs.length);
- SequenceFeature sf = sfs[0];
+ List<SequenceFeature> sfs = seq0.getSequenceFeatures();
+ assertEquals(1, sfs.size());
+ SequenceFeature sf = sfs.get(0);
assertEquals(1, sf.getBegin());
assertEquals(2, sf.getEnd());
import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
import jalview.datamodel.PDBEntry.Type;
import jalview.gui.JvOptionPane;
newDs = PA.getValue(sq, "datasetSequence");
assertNotNull(newDs);
assertNotSame(ds, newDs);
- SequenceFeature[] sfs = sq.getSequenceFeatures();
- assertNotNull(sfs);
- assertEquals(1, sfs.length);
- assertNotSame(sf1, sfs[0]);
- assertEquals(sf1, sfs[0]);
+ List<SequenceFeature> sfs = sq.getSequenceFeatures();
+ assertEquals(1, sfs.size());
+ assertNotSame(sf1, sfs.get(0));
+ assertEquals(sf1, sfs.get(0));
/*
* delete at start - no new dataset sequence created
assertSame(ds, PA.getValue(sq, "datasetSequence"));
sfs = sq.getSequenceFeatures();
assertNotNull(sfs);
- assertEquals(1, sfs.length);
- assertSame(sf1, sfs[0]);
+ assertEquals(1, sfs.size());
+ assertSame(sf1, sfs.get(0));
/*
* delete at end - no new dataset sequence created
SequenceI sq = new Sequence("test", "GATCAT");
sq.createDatasetSequence();
- assertNull(sq.getSequenceFeatures());
+ assertTrue(sq.getSequenceFeatures().isEmpty());
/*
* SequenceFeature on sequence
*/
SequenceFeature sf = new SequenceFeature("Cath", "desc", 2, 4, 2f, null);
sq.addSequenceFeature(sf);
- SequenceFeature[] sfs = sq.getSequenceFeatures();
- assertEquals(1, sfs.length);
- assertSame(sf, sfs[0]);
+ List<SequenceFeature> sfs = sq.getSequenceFeatures();
+ assertEquals(1, sfs.size());
+ assertSame(sf, sfs.get(0));
/*
* SequenceFeature on sequence and dataset sequence; returns that on
null);
sq.getDatasetSequence().addSequenceFeature(sf2);
sfs = sq.getSequenceFeatures();
- assertEquals(1, sfs.length);
- assertSame(sf, sfs[0]);
+ assertEquals(1, sfs.size());
+ assertSame(sf, sfs.get(0));
/*
* SequenceFeature on dataset sequence only
* Note JAL-2046: spurious: we have no use case for setting a non-dataset sequence's feature array to null at the moment.
*/
sq.setSequenceFeatures(null);
- assertNull(sq.getDatasetSequence().getSequenceFeatures());
+ assertTrue(sq.getDatasetSequence().getSequenceFeatures().isEmpty());
/*
* Corrupt case - no SequenceFeature, dataset's dataset is the original
assertTrue(e.getMessage().toLowerCase()
.contains("implementation error"));
}
- assertNull(sq.getSequenceFeatures());
+ assertTrue(sq.getSequenceFeatures().isEmpty());
}
/**
"group"));
sq.addDBRef(new DBRefEntry("source", "version", "accession"));
assertNull(sq.getDatasetSequence());
- assertNotNull(PA.getValue(sq, "sequenceFeatures")); // to be removed!
assertNotNull(PA.getValue(sq, "sequenceFeatureStore"));
assertNotNull(PA.getValue(sq, "dbrefs"));
assertSame(sq.getDatasetSequence(), rds);
// sequence features and dbrefs transferred to dataset sequence
- assertNull(PA.getValue(sq, "sequenceFeatures"));
assertNull(PA.getValue(sq, "sequenceFeatureStore"));
assertNull(PA.getValue(sq, "dbrefs"));
- assertNotNull(PA.getValue(rds, "sequenceFeatures"));
assertNotNull(PA.getValue(rds, "sequenceFeatureStore"));
assertNotNull(PA.getValue(rds, "dbrefs"));
}
assertEquals("CD", derived.getSequenceAsString());
assertSame(sq.getDatasetSequence(), derived.getDatasetSequence());
- assertNull(sq.sequenceFeatures);
- assertNull(derived.sequenceFeatures);
// derived sequence should access dataset sequence features
assertNotNull(sq.getSequenceFeatures());
- assertArrayEquals(sq.getSequenceFeatures(),
- derived.getSequenceFeatures());
+ assertEquals(sq.getSequenceFeatures(), derived.getSequenceFeatures());
/*
* verify we have primary db refs *just* for PDB IDs with associated
assertEquals(anns[0].score, seq1.getAnnotation()[0].score);
// copy has a copy of the sequence feature:
- SequenceFeature[] sfs = copy.getSequenceFeatures();
- assertEquals(1, sfs.length);
+ List<SequenceFeature> sfs = copy.getSequenceFeatures();
+ assertEquals(1, sfs.size());
if (seq1.getDatasetSequence() != null
&& copy.getDatasetSequence() == seq1.getDatasetSequence())
{
- assertTrue(sfs[0] == seq1.getSequenceFeatures()[0]);
+ assertSame(sfs.get(0), seq1.getSequenceFeatures().get(0));
}
else
{
- assertFalse(sfs[0] == seq1.getSequenceFeatures()[0]);
+ assertNotSame(sfs.get(0), seq1.getSequenceFeatures().get(0));
}
- assertTrue(sfs[0].equals(seq1.getSequenceFeatures()[0]));
+ assertEquals(sfs.get(0), seq1.getSequenceFeatures().get(0));
// copy has a copy of the PDB entry
Vector<PDBEntry> pdbs = copy.getAllPDBEntries();
/*
* the ID is also the group for features derived from structure data
*/
- assertNotNull(structureData.getSeqs().get(0).getSequenceFeatures()[0].featureGroup);
- assertEquals(
- structureData.getSeqs().get(0).getSequenceFeatures()[0].featureGroup,
- "localstruct.pdb");
+ String featureGroup = structureData.getSeqs().get(0)
+ .getSequenceFeatures().get(0).featureGroup;
+ assertNotNull(featureGroup);
+ assertEquals(featureGroup, "localstruct.pdb");
}
}
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.features.SequenceFeatures;
import jalview.gui.AlignFrame;
import jalview.gui.JvOptionPane;
import jalview.structure.StructureImportSettings;
import jalview.structure.StructureImportSettings.StructureParser;
import java.io.File;
+import java.util.List;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
/*
* 1GAQ/A
*/
- SequenceFeature[] sf = al.getSequenceAt(0).getSequenceFeatures();
- assertEquals(296, sf.length);
- assertEquals("RESNUM", sf[0].getType());
- assertEquals("GLU: 19 1gaqA", sf[0].getDescription());
- assertEquals("RESNUM", sf[295].getType());
- assertEquals("TYR: 314 1gaqA", sf[295].getDescription());
+ List<SequenceFeature> sf = al.getSequenceAt(0).getSequenceFeatures();
+ SequenceFeatures.sortFeatures(sf, true);
+ assertEquals(296, sf.size());
+ assertEquals("RESNUM", sf.get(0).getType());
+ assertEquals("GLU: 19 1gaqA", sf.get(0).getDescription());
+ assertEquals("RESNUM", sf.get(295).getType());
+ assertEquals("TYR: 314 1gaqA", sf.get(295).getDescription());
/*
* 1GAQ/B
*/
sf = al.getSequenceAt(1).getSequenceFeatures();
- assertEquals(98, sf.length);
- assertEquals("RESNUM", sf[0].getType());
- assertEquals("ALA: 1 1gaqB", sf[0].getDescription());
- assertEquals("RESNUM", sf[97].getType());
- assertEquals("ALA: 98 1gaqB", sf[97].getDescription());
+ SequenceFeatures.sortFeatures(sf, true);
+ assertEquals(98, sf.size());
+ assertEquals("RESNUM", sf.get(0).getType());
+ assertEquals("ALA: 1 1gaqB", sf.get(0).getDescription());
+ assertEquals("RESNUM", sf.get(97).getType());
+ assertEquals("ALA: 98 1gaqB", sf.get(97).getDescription());
/*
* 1GAQ/C
*/
sf = al.getSequenceAt(2).getSequenceFeatures();
- assertEquals(296, sf.length);
- assertEquals("RESNUM", sf[0].getType());
- assertEquals("GLU: 19 1gaqC", sf[0].getDescription());
- assertEquals("RESNUM", sf[295].getType());
- assertEquals("TYR: 314 1gaqC", sf[295].getDescription());
+ SequenceFeatures.sortFeatures(sf, true);
+ assertEquals(296, sf.size());
+ assertEquals("RESNUM", sf.get(0).getType());
+ assertEquals("GLU: 19 1gaqC", sf.get(0).getDescription());
+ assertEquals("RESNUM", sf.get(295).getType());
+ assertEquals("TYR: 314 1gaqC", sf.get(295).getDescription());
}
@Test(groups = { "Functional" })
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
import jalview.api.FeatureColourI;
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
+import jalview.datamodel.features.SequenceFeatures;
import jalview.gui.AlignFrame;
import jalview.gui.JvOptionPane;
/*
* verify (some) features on sequences
*/
- SequenceFeature[] sfs = al.getSequenceAt(0).getDatasetSequence()
+ List<SequenceFeature> sfs = al.getSequenceAt(0).getDatasetSequence()
.getSequenceFeatures(); // FER_CAPAA
- assertEquals(8, sfs.length);
- SequenceFeature sf = sfs[0];
+ SequenceFeatures.sortFeatures(sfs, true);
+ assertEquals(8, sfs.size());
+
+ /*
+ * verify (in ascending start position order)
+ */
+ SequenceFeature sf = sfs.get(0);
assertEquals("Pfam family%LINK%", sf.description);
assertEquals(0, sf.begin);
assertEquals(0, sf.end);
assertEquals("Pfam family|http://pfam.xfam.org/family/PF00111",
sf.links.get(0));
- sf = sfs[1];
+ sf = sfs.get(1);
+ assertEquals("Ferredoxin_fold Status: True Positive ", sf.description);
+ assertEquals(3, sf.begin);
+ assertEquals(93, sf.end);
+ assertEquals("uniprot", sf.featureGroup);
+ assertEquals("Cath", sf.type);
+
+ sf = sfs.get(2);
+ assertEquals("Fer2 Status: True Positive Pfam 8_8%LINK%",
+ sf.description);
+ assertEquals("Pfam 8_8|http://pfam.xfam.org/family/PF00111",
+ sf.links.get(0));
+ assertEquals(8, sf.begin);
+ assertEquals(83, sf.end);
+ assertEquals("uniprot", sf.featureGroup);
+ assertEquals("Pfam", sf.type);
+
+ sf = sfs.get(3);
assertEquals("Iron-sulfur (2Fe-2S)", sf.description);
assertEquals(39, sf.begin);
assertEquals(39, sf.end);
assertEquals("uniprot", sf.featureGroup);
assertEquals("METAL", sf.type);
- sf = sfs[2];
+
+ sf = sfs.get(4);
assertEquals("Iron-sulfur (2Fe-2S)", sf.description);
assertEquals(44, sf.begin);
assertEquals(44, sf.end);
assertEquals("uniprot", sf.featureGroup);
assertEquals("METAL", sf.type);
- sf = sfs[3];
+
+ sf = sfs.get(5);
assertEquals("Iron-sulfur (2Fe-2S)", sf.description);
assertEquals(47, sf.begin);
assertEquals(47, sf.end);
assertEquals("uniprot", sf.featureGroup);
assertEquals("METAL", sf.type);
- sf = sfs[4];
+
+ sf = sfs.get(6);
assertEquals("Iron-sulfur (2Fe-2S)", sf.description);
assertEquals(77, sf.begin);
assertEquals(77, sf.end);
assertEquals("uniprot", sf.featureGroup);
assertEquals("METAL", sf.type);
- sf = sfs[5];
- assertEquals("Fer2 Status: True Positive Pfam 8_8%LINK%",
- sf.description);
- assertEquals("Pfam 8_8|http://pfam.xfam.org/family/PF00111",
- sf.links.get(0));
- assertEquals(8, sf.begin);
- assertEquals(83, sf.end);
- assertEquals("uniprot", sf.featureGroup);
- assertEquals("Pfam", sf.type);
- sf = sfs[6];
- assertEquals("Ferredoxin_fold Status: True Positive ", sf.description);
- assertEquals(3, sf.begin);
- assertEquals(93, sf.end);
- assertEquals("uniprot", sf.featureGroup);
- assertEquals("Cath", sf.type);
- sf = sfs[7];
+
+ sf = sfs.get(7);
assertEquals(
"High confidence server. Only hits with scores over 0.8 are reported. PHOSPHORYLATION (T) 89_8%LINK%",
sf.description);
assertEquals(colours.get("METAL").getColour(), new Color(0xcc9900));
// verify feature on FER_CAPAA
- SequenceFeature[] sfs = al.getSequenceAt(0).getDatasetSequence()
+ List<SequenceFeature> sfs = al.getSequenceAt(0).getDatasetSequence()
.getSequenceFeatures();
- assertEquals(1, sfs.length);
- SequenceFeature sf = sfs[0];
+ assertEquals(1, sfs.size());
+ SequenceFeature sf = sfs.get(0);
assertEquals("Iron-sulfur,2Fe-2S", sf.description);
assertEquals(44, sf.begin);
assertEquals(45, sf.end);
// verify feature on FER1_SOLLC
sfs = al.getSequenceAt(2).getDatasetSequence().getSequenceFeatures();
- assertEquals(1, sfs.length);
- sf = sfs[0];
+ assertEquals(1, sfs.size());
+ sf = sfs.get(0);
assertEquals("uniprot", sf.description);
assertEquals(55, sf.begin);
assertEquals(130, sf.end);
featuresFile.parse(al.getDataset(), colours, true));
// verify feature on FER_CAPAA
- SequenceFeature[] sfs = al.getSequenceAt(0).getDatasetSequence()
+ List<SequenceFeature> sfs = al.getSequenceAt(0).getDatasetSequence()
.getSequenceFeatures();
- assertEquals(1, sfs.length);
- SequenceFeature sf = sfs[0];
+ assertEquals(1, sfs.size());
+ SequenceFeature sf = sfs.get(0);
// description parsed from Note attribute
assertEquals("Iron-sulfur (2Fe-2S),another note", sf.description);
assertEquals(39, sf.begin);
// verify feature on FER1_SOLLC1
sfs = al.getSequenceAt(2).getDatasetSequence().getSequenceFeatures();
- assertEquals(1, sfs.length);
- sf = sfs[0];
+ assertEquals(1, sfs.size());
+ sf = sfs.get(0);
// ID used for description if available
assertEquals("$23", sf.description);
assertEquals(55, sf.begin);
featuresFile.parse(al.getDataset(), colours, true));
// verify FER_CAPAA feature
- SequenceFeature[] sfs = al.getSequenceAt(0).getDatasetSequence()
+ List<SequenceFeature> sfs = al.getSequenceAt(0).getDatasetSequence()
.getSequenceFeatures();
- assertEquals(1, sfs.length);
- SequenceFeature sf = sfs[0];
+ assertEquals(1, sfs.size());
+ SequenceFeature sf = sfs.get(0);
assertEquals("Iron-sulfur (2Fe-2S)", sf.description);
assertEquals(39, sf.begin);
assertEquals(39, sf.end);
// verify FER1_SOLLC feature
sfs = al.getSequenceAt(2).getDatasetSequence().getSequenceFeatures();
- assertEquals(1, sfs.length);
- sf = sfs[0];
+ assertEquals(1, sfs.size());
+ sf = sfs.get(0);
assertEquals("Iron-phosphorus (2Fe-P)", sf.description);
assertEquals(86, sf.begin);
assertEquals(87, sf.end);
assertFalse("dummy replacement buggy for seq2",
placeholderseq.equals(seq2.getSequenceAsString()));
assertNotNull("No features added to seq1", seq1.getSequenceFeatures());
- assertEquals("Wrong number of features", 3,
- seq1.getSequenceFeatures().length);
- assertNull(seq2.getSequenceFeatures());
+ assertEquals("Wrong number of features", 3, seq1.getSequenceFeatures()
+ .size());
+ assertTrue(seq2.getSequenceFeatures().isEmpty());
assertEquals(
"Wrong number of features",
0,
seq2.getSequenceFeatures() == null ? 0 : seq2
- .getSequenceFeatures().length);
+ .getSequenceFeatures().size());
assertTrue(
"Expected at least one CDNA/Protein mapping for seq1",
dataset.getCodonFrame(seq1) != null
seq_original = al.getSequencesArray();
SequenceI[] seq_new = new SequenceI[al_input.getSequencesArray().length];
seq_new = al_input.getSequencesArray();
- SequenceFeature[] sequenceFeatures_original, sequenceFeatures_new;
+ List<SequenceFeature> sequenceFeatures_original;
+ List<SequenceFeature> sequenceFeatures_new;
AlignmentAnnotation annot_original, annot_new;
//
for (int i = 0; i < al.getSequencesArray().length; i++)
&& seq_new[in].getSequenceFeatures() != null)
{
System.out.println("There are feature!!!");
- sequenceFeatures_original = new SequenceFeature[seq_original[i]
- .getSequenceFeatures().length];
sequenceFeatures_original = seq_original[i]
.getSequenceFeatures();
- sequenceFeatures_new = new SequenceFeature[seq_new[in]
- .getSequenceFeatures().length];
sequenceFeatures_new = seq_new[in].getSequenceFeatures();
- assertEquals("different number of features",
- seq_original[i].getSequenceFeatures().length,
- seq_new[in].getSequenceFeatures().length);
+ assertEquals("different number of features", seq_original[i]
+ .getSequenceFeatures().size(), seq_new[in]
+ .getSequenceFeatures().size());
- for (int feat = 0; feat < seq_original[i].getSequenceFeatures().length; feat++)
+ for (int feat = 0; feat < seq_original[i].getSequenceFeatures()
+ .size(); feat++)
{
assertEquals("Different features",
- sequenceFeatures_original[feat],
- sequenceFeatures_new[feat]);
+ sequenceFeatures_original.get(feat),
+ sequenceFeatures_new.get(feat));
}
}
// compare alignment annotation
assertEquals("match$17_5_30", newseqs.get(0).getName());
assertNotNull(newseqs.get(0).getSequenceFeatures());
- assertEquals(1, newseqs.get(0).getSequenceFeatures().length);
- SequenceFeature sf = newseqs.get(0).getSequenceFeatures()[0];
+ assertEquals(1, newseqs.get(0).getSequenceFeatures().size());
+ SequenceFeature sf = newseqs.get(0).getSequenceFeatures().get(0);
assertEquals(1, sf.getBegin());
assertEquals(26, sf.getEnd());
assertEquals("Pfam", sf.getType());
import jalview.schemes.FeatureColour;
import java.awt.Color;
+import java.util.List;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
@BeforeMethod(alwaysRun = true)
public void setUpBeforeTest()
{
- SequenceFeature[] sfs = seq.getSequenceFeatures();
- if (sfs != null)
+ List<SequenceFeature> sfs = seq.getSequenceFeatures();
+ for (SequenceFeature sf : sfs)
{
- for (SequenceFeature sf : sfs)
- {
- seq.deleteFeature(sf);
- }
+ seq.deleteFeature(sf);
}
fr.findAllFeatures(true);
/*
* Verify a RESNUM sequence feature in the PDBfile sequence
*/
- SequenceFeature sf = pmap.getSeqs().get(0).getSequenceFeatures()[0];
+ SequenceFeature sf = pmap.getSeqs().get(0).getSequenceFeatures().get(0);
assertEquals("RESNUM", sf.getType());
assertEquals("1gaq", sf.getFeatureGroup());
assertEquals("GLU: 19 1gaqA", sf.getDescription());
* sequence
*/
StructureMapping map = sm.getMapping("examples/1gaq.txt")[0];
- sf = map.sequence.getSequenceFeatures()[0];
+ sf = map.sequence.getSequenceFeatures().get(0);
assertEquals("RESNUM", sf.getType());
assertEquals("1gaq", sf.getFeatureGroup());
assertEquals("ALA: 1 1gaqB", sf.getDescription());
package jalview.ws.seqfetcher;
import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
SequenceI seq = alsq.getSequenceAt(0);
assertEquals("Wrong sequence name", embl.getDbSource() + "|"
+ retrievalId, seq.getName());
- SequenceFeature[] sfs = seq.getSequenceFeatures();
- assertNotNull("Sequence features missing", sfs);
+ List<SequenceFeature> sfs = seq.getSequenceFeatures();
+ assertFalse("Sequence features missing", sfs.isEmpty());
assertTrue(
"Feature not CDS",
FeatureProperties.isCodingFeature(embl.getDbSource(),
- sfs[0].getType()));
- assertEquals(embl.getDbSource(), sfs[0].getFeatureGroup());
+ sfs.get(0).getType()));
+ assertEquals(embl.getDbSource(), sfs.get(0).getFeatureGroup());
DBRefEntry[] dr = DBRefUtils.selectRefs(seq.getDBRefs(),
new String[] { DBRefSource.UNIPROT });
assertNotNull(dr);