}
for (int i = 0; i < features.length; i++)
{
- if (features[i].getFeatureGroup() != null
- && features[i].getFeatureGroup().equals(pdbid))
+ SequenceFeature feature = features[i];
+ if (feature.getFeatureGroup() != null
+ && feature.getFeatureGroup().equals(pdbid))
{
- int newBegin = 1 + residues.elementAt(features[i].getBegin()
- - offset).atoms
+ int newBegin = 1 + residues.elementAt(feature.getBegin() - offset).atoms
.elementAt(0).alignmentMapping;
- int newEnd = 1 + residues.elementAt(features[i].getEnd() - offset).atoms
+ int newEnd = 1 + residues.elementAt(feature.getEnd() - offset).atoms
.elementAt(0).alignmentMapping;
- SequenceFeature tx = new SequenceFeature(features[i], newBegin,
- newEnd, features[i].getFeatureGroup());
+ SequenceFeature tx = new SequenceFeature(feature, newBegin, newEnd,
+ feature.getFeatureGroup(), feature.getScore());
tx.setStatus(status
+ ((tx.getStatus() == null || tx.getStatus().length() == 0) ? ""
: ":" + tx.getStatus()));
&& !residues.isEmpty()
&& residues.lastElement().atoms.get(0).resNumber == currAtom.resNumber)
{
- SequenceFeature sf = new SequenceFeature("INSERTION",
- currAtom.resName + ":" + currAtom.resNumIns + " " + pdbid
- + id, "", offset + count - 1, offset + count - 1,
- "PDB_INS");
+ String desc = currAtom.resName + ":" + currAtom.resNumIns + " "
+ + pdbid + id;
+ SequenceFeature sf = new SequenceFeature("INSERTION", desc, offset
+ + count - 1, offset + count - 1, "PDB_INS");
resFeatures.addElement(sf);
residues.lastElement().atoms.addAll(resAtoms);
}
else
{
-
// Make a new Residue object with the new atoms vector
residues.addElement(new Residue(resAtoms, resNumber - 1, count));
Residue tmpres = residues.lastElement();
Atom tmpat = tmpres.atoms.get(0);
// Make A new SequenceFeature for the current residue numbering
- SequenceFeature sf = new SequenceFeature(RESNUM_FEATURE, tmpat.resName
- + ":" + tmpat.resNumIns + " " + pdbid + id, "", offset
- + count, offset + count, pdbid);
+ String desc = tmpat.resName
+ + ":" + tmpat.resNumIns + " " + pdbid + id;
+ SequenceFeature sf = new SequenceFeature(RESNUM_FEATURE, desc,
+ offset + count, offset + count, pdbid);
resFeatures.addElement(sf);
resAnnotation.addElement(new Annotation(tmpat.tfactor));
// Keep totting up the sequence
int newBegin = Math.min(mappedTo[0], mappedTo[1]);
int newEnd = Math.max(mappedTo[0], mappedTo[1]);
SequenceFeature copy = new SequenceFeature(sf, newBegin, newEnd,
- sf.getFeatureGroup());
+ sf.getFeatureGroup(), sf.getScore());
copyTo.addSequenceFeature(copy);
count++;
}
String trans3Char = StringUtils
.toSentenceCase(ResidueProperties.aa2Triplet.get(trans));
String desc = "p." + residue3Char + peptidePos + trans3Char;
- // set score to 0f so 'graduated colour' option is offered! JAL-2060
SequenceFeature sf = new SequenceFeature(
SequenceOntologyI.SEQUENCE_VARIANT, desc, peptidePos,
- peptidePos, 0f, var.getSource());
+ peptidePos, var.getSource());
StringBuilder attributes = new StringBuilder(32);
String id = (String) var.variant.getValue(ID);
if (id != null)
helices.put(close, helix);
// Record helix as featuregroup
- result.add(new SequenceFeature("RNA helix", "", "", open, close,
+ result.add(new SequenceFeature("RNA helix", "", open, close,
String.valueOf(helix)));
lastopen = open;
if (start <= end)
{
seqs[rsize] = sg.getSequenceAt(i);
- features[rsize] = new SequenceFeature(null, null, null, start,
+ features[rsize] = new SequenceFeature(null, null, start,
end, "Jalview");
rsize++;
}
*/
sequences[0].deleteFeature(sf);
SequenceFeature newSf = new SequenceFeature(sf, newBegin, newEnd,
- enteredGroup);
+ enteredGroup, sf.getScore());
newSf.setDescription(enteredDesc);
ffile.parseDescriptionHTML(newSf, false);
// amend features dialog only updates one sequence at a time
{
SequenceFeature sf = features[i];
SequenceFeature sf2 = new SequenceFeature(enteredType,
- enteredDesc, sf.getBegin(), sf.getEnd(), Float.NaN,
- enteredGroup);
+ enteredDesc, sf.getBegin(), sf.getEnd(), enteredGroup);
ffile.parseDescriptionHTML(sf2, false);
sequences[i].addSequenceFeature(sf2);
}
{
seqs[i] = match.getSequence().getDatasetSequence();
- features[i] = new SequenceFeature(searchString,
- "Search Results", null, match.getStart(), match.getEnd(),
- "Search Results");
+ features[i] = new SequenceFeature(searchString, "Search Results",
+ match.getStart(), match.getEnd(), "Search Results");
i++;
}
int newBegin = copy.getBegin() - cSize;
int newEnd = copy.getEnd() - cSize;
SequenceFeature newSf = new SequenceFeature(feature, newBegin,
- newEnd, feature.getFeatureGroup());
+ newEnd, feature.getFeatureGroup(), feature.getScore());
sequence.deleteFeature(feature);
sequence.addSequenceFeature(newSf);
// feature.setBegin(newBegin);
if (newEnd >= newBegin)
{
sequence.addSequenceFeature(new SequenceFeature(feature, newBegin,
- newEnd, feature.getFeatureGroup()));
+ newEnd, feature.getFeatureGroup(), feature.getScore()));
}
// if (feature.getBegin() > feature.getEnd())
// {
for (int i = 0, v = 0; i < frange.length; i += 2, v++)
{
vf[v] = new SequenceFeature(f, frange[i], frange[i + 1],
- f.getFeatureGroup());
+ f.getFeatureGroup(), f.getScore());
if (frange.length > 2)
{
vf[v].setDescription(f.getDescription() + "\nPart " + (v + 1));
public final String featureGroup;
- public float score;
+ public final float score;
public String description;
*/
public SequenceFeature(SequenceFeature cpy)
{
- this(cpy, cpy.getBegin(), cpy.getEnd(), cpy.getFeatureGroup());
+ this(cpy, cpy.getBegin(), cpy.getEnd(), cpy.getFeatureGroup(), cpy
+ .getScore());
}
/**
public SequenceFeature(String theType, String theDesc, int theBegin,
int theEnd, float theScore, String group)
{
- this(theType, theDesc, theBegin, theEnd, group);
+ this.type = theType;
+ this.description = theDesc;
+ this.begin = theBegin;
+ this.end = theEnd;
+ this.featureGroup = group;
this.score = theScore;
}
/**
- * A copy constructor that allows the begin and end positions and group to be
- * modified
+ * A copy constructor that allows the value of final fields to be 'modified'
*
* @param sf
* @param newBegin
* @param newEnd
* @param newGroup
+ * @param newScore
*/
public SequenceFeature(SequenceFeature sf, int newBegin, int newEnd,
- String newGroup)
+ String newGroup, float newScore)
{
- this(sf.getType(), newBegin, newEnd, newGroup);
- score = sf.score;
- description = sf.description;
+ this(sf.getType(), sf.getDescription(), newBegin, newEnd, newScore,
+ newGroup);
+
if (sf.otherDetails != null)
{
otherDetails = new HashMap<String, Object>();
}
/**
- * Constructor that sets the final fields type, begin, end, group
- *
- * @param theType
- * @param theBegin
- * @param theEnd
- * @param theGroup
- */
- private SequenceFeature(String theType, int theBegin, int theEnd,
- String theGroup)
- {
- type = theType;
- begin = theBegin;
- end = theEnd;
- featureGroup = theGroup;
- }
-
- /**
* Two features are considered equal if they have the same type, group,
* description, start, end, phase, strand, and (if present) 'Name', ID' and
* 'Parent' attributes.
return score;
}
- public void setScore(float value)
- {
- score = value;
- }
-
/**
* Used for getting values which are not in the basic set. eg STRAND, PHASE
* for GFF file
{
newBegin = Math.max(1, newBegin);
SequenceFeature sf2 = new SequenceFeature(sf, newBegin, newEnd,
- sf.getFeatureGroup());
+ sf.getFeatureGroup(), sf.getScore());
addFeature(sf2);
}
delete(sf);
protected SequenceFeature makeCdsFeature(String type, String desc,
int begin, int end, String group, Map<String, String> vals)
{
- SequenceFeature sf = new SequenceFeature(type, desc, begin, end,
- Float.NaN, group);
+ SequenceFeature sf = new SequenceFeature(type, desc, begin, end, group);
if (!vals.isEmpty())
{
int newBegin = Math.min(mappedRange[0], mappedRange[1]);
int newEnd = Math.max(mappedRange[0], mappedRange[1]);
SequenceFeature copy = new SequenceFeature(sf, newBegin, newEnd,
- group);
+ group, sf.getScore());
targetSequence.addSequenceFeature(copy);
/*
*/
sequences.get(0).deleteFeature(sf);
SequenceFeature newSf = new SequenceFeature(sf, newBegin, newEnd,
- enteredGroup);
+ enteredGroup, sf.getScore());
sf.setDescription(enteredDescription);
ffile.parseDescriptionHTML(newSf, false);
// amend features dialog only updates one sequence at a time
SequenceFeature sf = features.get(i);
SequenceFeature sf2 = new SequenceFeature(enteredType,
enteredDescription, sf.getBegin(), sf.getEnd(),
- Float.NaN, enteredGroup);
+ enteredGroup);
ffile.parseDescriptionHTML(sf2, false);
sequences.get(i).addSequenceFeature(sf2);
}
for (SearchResultMatchI match : searchResults.getResults())
{
seqs.add(match.getSequence().getDatasetSequence());
- features.add(new SequenceFeature(searchString, desc, null, match
+ features.add(new SequenceFeature(searchString, desc,
+ match
.getStart(), match.getEnd(), desc));
}
import jalview.datamodel.GraphLine;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.RnaViewerModel;
+import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.datamodel.StructureViewerModel;
Features[] features = jseqs[i].getFeatures();
for (int f = 0; f < features.length; f++)
{
- jalview.datamodel.SequenceFeature sf = new jalview.datamodel.SequenceFeature(
- features[f].getType(), features[f].getDescription(),
- features[f].getStatus(), features[f].getBegin(),
- features[f].getEnd(), features[f].getFeatureGroup());
-
- sf.setScore(features[f].getScore());
+ SequenceFeature sf = new SequenceFeature(features[f].getType(),
+ features[f].getDescription(), features[f].getBegin(),
+ features[f].getEnd(), features[f].getScore(),
+ features[f].getFeatureGroup());
+ sf.setStatus(features[f].getStatus());
for (int od = 0; od < features[f].getOtherDataCount(); od++)
{
OtherData keyValue = features[f].getOtherData(od);
import jalview.binding.UserColours;
import jalview.binding.Viewport;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceFeature;
import jalview.io.FileFormat;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
Features[] features = JSEQ[i].getFeatures();
for (int f = 0; f < features.length; f++)
{
- jalview.datamodel.SequenceFeature sf = new jalview.datamodel.SequenceFeature(
- features[f].getType(), features[f].getDescription(),
- features[f].getStatus(), features[f].getBegin(),
+ SequenceFeature sf = new SequenceFeature(features[f].getType(),
+ features[f].getDescription(), features[f].getBegin(),
features[f].getEnd(), null);
-
+ sf.setStatus(features[f].getStatus());
al.getSequenceAt(i).getDatasetSequence().addSequenceFeature(sf);
}
}
if (start <= end)
{
seqs.add(sg.getSequenceAt(i).getDatasetSequence());
- features.add(new SequenceFeature(null, null, null, start, end, null));
+ features.add(new SequenceFeature(null, null, start, end, null));
}
}
Color colour = ColorUtils.createColourFromName(ft);
featureColours.put(ft, new FeatureColour(colour));
}
- SequenceFeature sf = new SequenceFeature(ft, desc, "", startPos,
- endPos, featureGroup);
+ SequenceFeature sf = null;
if (gffColumns.length > 6)
{
float score = Float.NaN;
try
{
score = new Float(gffColumns[6]).floatValue();
- // update colourgradient bounds if allowed to
} catch (NumberFormatException ex)
{
- // leave as NaN
+ sf = new SequenceFeature(ft, desc, startPos, endPos, featureGroup);
}
- sf.setScore(score);
+ sf = new SequenceFeature(ft, desc, startPos, endPos, score,
+ featureGroup);
+ }
+ else
+ {
+ sf = new SequenceFeature(ft, desc, startPos, endPos, featureGroup);
}
parseDescriptionHTML(sf, removeHTML);
int new_pos = posmap[k]; // look up nearest seqeunce
// position to this column
SequenceFeature feat = new SequenceFeature(type, desc,
- new_pos, new_pos, 0f, null);
+ new_pos, new_pos, null);
seqO.addSequenceFeature(feat);
}
*/
int sequenceFeatureLength = 1 + sf.getEnd() - sf.getBegin();
SequenceFeature sf2 = new SequenceFeature(sf, 1,
- sequenceFeatureLength, sf.getFeatureGroup());
+ sequenceFeatureLength, sf.getFeatureGroup(), sf.getScore());
mappedSequence.addSequenceFeature(sf2);
/*
private SequenceFeature getJalviewSeqFeature(RangeAnnotation dseta)
{
int[] se = getBounds(dseta);
- SequenceFeature sf = new jalview.datamodel.SequenceFeature(
- dseta.getType(), dseta.getDescription(), dseta.getStatus(),
- se[0], se[1], dseta.getGroup());
+
+ /*
+ * try to identify feature score
+ */
+ boolean scoreFound = false;
+ float theScore = 0f;
+ String featureType = dseta.getType();
+ if (dseta.getScoreCount() > 0)
+ {
+ Enumeration scr = dseta.enumerateScore();
+ while (scr.hasMoreElements())
+ {
+ Score score = (Score) scr.nextElement();
+ if (score.getName().equals(featureType))
+ {
+ theScore = score.getContent();
+ scoreFound = true;
+ }
+ }
+ }
+
+ SequenceFeature sf = null;
+ if (scoreFound)
+ {
+ sf = new SequenceFeature(featureType, dseta.getDescription(), se[0],
+ se[1], theScore, dseta.getGroup());
+ }
+ else
+ {
+ sf = new SequenceFeature(featureType, dseta.getDescription(), se[0],
+ se[1], dseta.getGroup());
+ }
+ sf.setStatus(dseta.getStatus());
if (dseta.getLinkCount() > 0)
{
Link[] links = dseta.getLink();
while (scr.hasMoreElements())
{
Score score = (Score) scr.nextElement();
- if (score.getName().equals(sf.getType()))
- {
- sf.setScore(score.getContent());
- }
- else
+ if (!score.getName().equals(sf.getType()))
{
sf.setValue(score.getName(), "" + score.getContent());
}
for (UniprotFeature uf : entry.getFeature())
{
SequenceFeature copy = new SequenceFeature(uf.getType(),
- uf.getDescription(), uf.getStatus(), uf.getBegin(),
- uf.getEnd(), "Uniprot");
+ uf.getDescription(), uf.getBegin(), uf.getEnd(), "Uniprot");
+ copy.setStatus(uf.getStatus());
sequence.addSequenceFeature(copy);
}
}
*/
package jalview.ws.jws2;
-import jalview.api.AlignCalcWorkerI;
import jalview.api.FeatureColourI;
import jalview.bin.Cache;
import jalview.datamodel.AlignmentAnnotation;
}
if (vals.hasNext())
{
+ val = vals.next().floatValue();
sf = new SequenceFeature(type[0], type[1],
- base + rn.from, base + rn.to, val = vals.next()
- .floatValue(), methodName);
+ base + rn.from, base + rn.to, val, methodName);
}
else
{
- sf = new SequenceFeature(type[0], type[1], null, base
- + rn.from, base + rn.to, methodName);
+ sf = new SequenceFeature(type[0], type[1],
+ base + rn.from, base + rn.to, methodName);
}
dseq.addSequenceFeature(sf);
if (last != val && !Float.isNaN(last))
AlignmentI al = new Alignment(sqset);
al.setDataset(null);
AlignmentI ds = al.getDataset();
- SequenceFeature sf1 = new SequenceFeature("f1", "foo", "bleh", 2, 3,
- "far"), sf2 = new SequenceFeature("f2", "foo", "bleh", 2, 3,
- "far");
+ SequenceFeature sf1 = new SequenceFeature("f1", "foo", 2, 3, "far");
+ SequenceFeature sf2 = new SequenceFeature("f2", "foo", 2, 3, "far");
ds.getSequenceAt(0).addSequenceFeature(sf1);
Hashtable unq = SeqsetUtils.uniquify(sqset, true);
SequenceI[] sqset2 = new SequenceI[] {
SequenceI ds = al.getSequenceAt(i).getDatasetSequence();
if (sf1[i * 2] > 0)
{
- ds.addSequenceFeature(new SequenceFeature("sf1", "sf1", "sf1",
- sf1[i * 2], sf1[i * 2 + 1], "sf1"));
+ ds.addSequenceFeature(new SequenceFeature("sf1", "sf1", sf1[i * 2],
+ sf1[i * 2 + 1], "sf1"));
}
if (sf2[i * 2] > 0)
{
- ds.addSequenceFeature(new SequenceFeature("sf2", "sf2", "sf2",
- sf2[i * 2], sf2[i * 2 + 1], "sf2"));
+ ds.addSequenceFeature(new SequenceFeature("sf2", "sf2", sf2[i * 2],
+ sf2[i * 2 + 1], "sf2"));
}
if (sf3[i * 2] > 0)
{
- ds.addSequenceFeature(new SequenceFeature("sf3", "sf3", "sf3",
- sf3[i * 2], sf3[i * 2 + 1], "sf3"));
+ ds.addSequenceFeature(new SequenceFeature("sf3", "sf3", sf3[i * 2],
+ sf3[i * 2 + 1], "sf3"));
}
}
alf.setShowSeqFeatures(true);
// changing score breaks equals:
float restoref = sf2.getScore();
- sf2.setScore(12.4f);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(),
+ sf2.getFeatureGroup(), 10f);
assertFalse(sf1.equals(sf2));
- sf2.setScore(restoref);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(),
+ sf2.getFeatureGroup(), restoref);
// NaN doesn't match a number
restoref = sf2.getScore();
- sf2.setScore(Float.NaN);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(),
+ sf2.getFeatureGroup(), Float.NaN);
assertFalse(sf1.equals(sf2));
// NaN matches NaN
- sf1.setScore(Float.NaN);
+ sf1 = new SequenceFeature(sf1, sf1.getBegin(), sf1.getEnd(),
+ sf1.getFeatureGroup(), Float.NaN);
assertTrue(sf1.equals(sf2));
- sf1.setScore(restoref);
- sf2.setScore(restoref);
+ sf1 = new SequenceFeature(sf1, sf1.getBegin(), sf1.getEnd(),
+ sf1.getFeatureGroup(), restoref);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(),
+ sf2.getFeatureGroup(), restoref);
// changing start position breaks equals:
int restorei = sf2.getBegin();
- sf2 = new SequenceFeature(sf2, 21, sf2.getEnd(), sf2.getFeatureGroup());
+ sf2 = new SequenceFeature(sf2, 21, sf2.getEnd(), sf2.getFeatureGroup(), sf2.getScore());
assertFalse(sf1.equals(sf2));
sf2 = new SequenceFeature(sf2, restorei, sf2.getEnd(),
- sf2.getFeatureGroup());
+ sf2.getFeatureGroup(), sf2.getScore());
// changing end position breaks equals:
restorei = sf2.getEnd();
sf2 = new SequenceFeature(sf2, sf2.getBegin(), 32,
- sf2.getFeatureGroup());
+ sf2.getFeatureGroup(), sf2.getScore());
assertFalse(sf1.equals(sf2));
sf2 = new SequenceFeature(sf2, sf2.getBegin(), restorei,
- sf2.getFeatureGroup());
+ sf2.getFeatureGroup(), sf2.getScore());
// changing feature group breaks equals:
restores = sf2.getFeatureGroup();
- sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), "Group");
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), "Group", sf2.getScore());
assertFalse(sf1.equals(sf2));
- sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), restores);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), restores, sf2.getScore());
// changing ID breaks equals:
restores = (String) sf2.getValue("ID");
* Note JAL-2046: spurious: we have no use case for this at the moment.
* This test also buggy - as sf2.equals(sf), no new feature is added
*/
- SequenceFeature sf2 = new SequenceFeature("Scop", "desc", 2, 5, 1f,
+ SequenceFeature sf2 = new SequenceFeature("Cath", "desc", 2, 4, 2f,
null);
sq.getDatasetSequence().addSequenceFeature(sf2);
sfs = sq.getSequenceFeatures();
assertEquals(Color.WHITE, fc.getColor(sf));
// score 120 is adjusted to top of range
- sf.setScore(120f);
+ sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(),
+ sf.getFeatureGroup(), 120f);
assertEquals(Color.BLACK, fc.getColor(sf));
// value below threshold is still rendered
// setting threshold has no effect yet...
fc.setThreshold(60f);
- sf.setScore(36f);
+ sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(),
+ sf.getFeatureGroup(), 36f);
assertTrue(fc.isColored(sf));
assertEquals(new Color(204, 204, 204), fc.getColor(sf));
// colour is still returned though ?!?
assertEquals(new Color(204, 204, 204), fc.getColor(sf));
- sf.setScore(84); // above threshold now
+ sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(),
+ sf.getFeatureGroup(), 84f);
+ // above threshold now
assertTrue(fc.isColored(sf));
assertEquals(new Color(51, 51, 51), fc.getColor(sf));
}