From b9d3d1f71c6a8aee09cd23e1303b062cbe43a239 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 25 May 2017 11:54:39 +0100 Subject: [PATCH] JAL-2050 make SequenceFeature.score final, adjust constructor calls --- src/MCview/PDBChain.java | 30 ++++++------- src/jalview/analysis/AlignmentUtils.java | 5 +-- src/jalview/analysis/Rna.java | 2 +- src/jalview/appletgui/APopupMenu.java | 2 +- src/jalview/appletgui/FeatureRenderer.java | 5 +-- src/jalview/appletgui/Finder.java | 5 +-- src/jalview/commands/EditCommand.java | 4 +- src/jalview/datamodel/Mapping.java | 2 +- src/jalview/datamodel/SequenceFeature.java | 45 ++++++-------------- src/jalview/datamodel/features/FeatureStore.java | 2 +- src/jalview/datamodel/xdb/embl/EmblEntry.java | 3 +- src/jalview/ext/ensembl/EnsemblSeqProxy.java | 2 +- src/jalview/gui/FeatureRenderer.java | 4 +- src/jalview/gui/Finder.java | 3 +- src/jalview/gui/Jalview2XML.java | 12 +++--- src/jalview/gui/Jalview2XML_V1.java | 8 ++-- src/jalview/gui/PopupMenu.java | 2 +- src/jalview/io/FeaturesFile.java | 13 +++--- src/jalview/io/StockholmFile.java | 2 +- src/jalview/io/gff/Gff3Helper.java | 2 +- src/jalview/io/vamsas/Sequencefeature.java | 42 ++++++++++++++---- src/jalview/ws/dbsources/Uniprot.java | 4 +- src/jalview/ws/jws2/AADisorderClient.java | 9 ++-- test/jalview/analysis/SeqsetUtilsTest.java | 5 +-- .../scoremodels/FeatureDistanceModelTest.java | 12 +++--- test/jalview/datamodel/SequenceFeatureTest.java | 30 +++++++------ test/jalview/datamodel/SequenceTest.java | 2 +- test/jalview/schemes/FeatureColourTest.java | 10 +++-- 28 files changed, 142 insertions(+), 125 deletions(-) diff --git a/src/MCview/PDBChain.java b/src/MCview/PDBChain.java index 1f47014..ef86cfd 100755 --- a/src/MCview/PDBChain.java +++ b/src/MCview/PDBChain.java @@ -204,16 +204,16 @@ public class PDBChain } 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())); @@ -355,25 +355,25 @@ public class PDBChain && !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 diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 66be623..69ac947 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -2134,7 +2134,7 @@ public class AlignmentUtils 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++; } @@ -2439,10 +2439,9 @@ public class AlignmentUtils 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) diff --git a/src/jalview/analysis/Rna.java b/src/jalview/analysis/Rna.java index 34233f0..3108ef3 100644 --- a/src/jalview/analysis/Rna.java +++ b/src/jalview/analysis/Rna.java @@ -466,7 +466,7 @@ public class Rna 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; diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 8fd317a..83e8cf8 100644 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -830,7 +830,7 @@ public class APopupMenu extends java.awt.PopupMenu implements 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++; } diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index 81b207f..b9e92e2 100644 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -431,7 +431,7 @@ public class FeatureRenderer extends */ 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 @@ -463,8 +463,7 @@ public class FeatureRenderer extends { 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); } diff --git a/src/jalview/appletgui/Finder.java b/src/jalview/appletgui/Finder.java index a342736..cd5030a 100644 --- a/src/jalview/appletgui/Finder.java +++ b/src/jalview/appletgui/Finder.java @@ -123,9 +123,8 @@ public class Finder extends Panel implements ActionListener { 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++; } diff --git a/src/jalview/commands/EditCommand.java b/src/jalview/commands/EditCommand.java index 388c533..f36b55f 100644 --- a/src/jalview/commands/EditCommand.java +++ b/src/jalview/commands/EditCommand.java @@ -1152,7 +1152,7 @@ public class EditCommand implements CommandI 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); @@ -1180,7 +1180,7 @@ public class EditCommand implements CommandI if (newEnd >= newBegin) { sequence.addSequenceFeature(new SequenceFeature(feature, newBegin, - newEnd, feature.getFeatureGroup())); + newEnd, feature.getFeatureGroup(), feature.getScore())); } // if (feature.getBegin() > feature.getEnd()) // { diff --git a/src/jalview/datamodel/Mapping.java b/src/jalview/datamodel/Mapping.java index 5a4689d..c741603 100644 --- a/src/jalview/datamodel/Mapping.java +++ b/src/jalview/datamodel/Mapping.java @@ -531,7 +531,7 @@ public class Mapping 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)); diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index 4df57ef..045bbbd 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -70,7 +70,7 @@ public class SequenceFeature implements FeatureLocationI public final String featureGroup; - public float score; + public final float score; public String description; @@ -91,7 +91,8 @@ public class SequenceFeature implements FeatureLocationI */ public SequenceFeature(SequenceFeature cpy) { - this(cpy, cpy.getBegin(), cpy.getEnd(), cpy.getFeatureGroup()); + this(cpy, cpy.getBegin(), cpy.getEnd(), cpy.getFeatureGroup(), cpy + .getScore()); } /** @@ -127,25 +128,29 @@ public class SequenceFeature implements FeatureLocationI 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(); @@ -165,23 +170,6 @@ public class SequenceFeature implements FeatureLocationI } /** - * 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. @@ -339,11 +327,6 @@ public class SequenceFeature implements FeatureLocationI 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 diff --git a/src/jalview/datamodel/features/FeatureStore.java b/src/jalview/datamodel/features/FeatureStore.java index 7218b38..332e9ec 100644 --- a/src/jalview/datamodel/features/FeatureStore.java +++ b/src/jalview/datamodel/features/FeatureStore.java @@ -1046,7 +1046,7 @@ public class FeatureStore { newBegin = Math.max(1, newBegin); SequenceFeature sf2 = new SequenceFeature(sf, newBegin, newEnd, - sf.getFeatureGroup()); + sf.getFeatureGroup(), sf.getScore()); addFeature(sf2); } delete(sf); diff --git a/src/jalview/datamodel/xdb/embl/EmblEntry.java b/src/jalview/datamodel/xdb/embl/EmblEntry.java index 6f9c884..c3d4e66 100644 --- a/src/jalview/datamodel/xdb/embl/EmblEntry.java +++ b/src/jalview/datamodel/xdb/embl/EmblEntry.java @@ -594,8 +594,7 @@ public class EmblEntry protected SequenceFeature makeCdsFeature(String type, String desc, int begin, int end, String group, Map vals) { - SequenceFeature sf = new SequenceFeature(type, desc, begin, end, - Float.NaN, group); + SequenceFeature sf = new SequenceFeature(type, desc, begin, end, group); if (!vals.isEmpty()) { diff --git a/src/jalview/ext/ensembl/EnsemblSeqProxy.java b/src/jalview/ext/ensembl/EnsemblSeqProxy.java index dcf2eb4..79d6c0a 100644 --- a/src/jalview/ext/ensembl/EnsemblSeqProxy.java +++ b/src/jalview/ext/ensembl/EnsemblSeqProxy.java @@ -691,7 +691,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient 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); /* diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index c6610e1..ac56590 100644 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -449,7 +449,7 @@ public class FeatureRenderer extends */ 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 @@ -471,7 +471,7 @@ public class FeatureRenderer extends 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); } diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index 625fc27..81de48f 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -222,7 +222,8 @@ public class Finder extends GFinder 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)); } diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 6361caf..d6e0123 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -32,6 +32,7 @@ import jalview.datamodel.AlignmentI; 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; @@ -2986,12 +2987,11 @@ public class Jalview2XML 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); diff --git a/src/jalview/gui/Jalview2XML_V1.java b/src/jalview/gui/Jalview2XML_V1.java index cc2f636..b17d060 100755 --- a/src/jalview/gui/Jalview2XML_V1.java +++ b/src/jalview/gui/Jalview2XML_V1.java @@ -36,6 +36,7 @@ import jalview.binding.Tree; 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; @@ -224,11 +225,10 @@ public class Jalview2XML_V1 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); } } diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 3de7c3c..c27aeee 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -1904,7 +1904,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener 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)); } } diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index a3cab6b..e1fccaf 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -373,20 +373,23 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI 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); diff --git a/src/jalview/io/StockholmFile.java b/src/jalview/io/StockholmFile.java index c2f3683..8fe7f82 100644 --- a/src/jalview/io/StockholmFile.java +++ b/src/jalview/io/StockholmFile.java @@ -412,7 +412,7 @@ public class StockholmFile extends AlignFile 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); } diff --git a/src/jalview/io/gff/Gff3Helper.java b/src/jalview/io/gff/Gff3Helper.java index 8af3933..28941f5 100644 --- a/src/jalview/io/gff/Gff3Helper.java +++ b/src/jalview/io/gff/Gff3Helper.java @@ -312,7 +312,7 @@ public class Gff3Helper extends GffHelperBase */ int sequenceFeatureLength = 1 + sf.getEnd() - sf.getBegin(); SequenceFeature sf2 = new SequenceFeature(sf, 1, - sequenceFeatureLength, sf.getFeatureGroup()); + sequenceFeatureLength, sf.getFeatureGroup(), sf.getScore()); mappedSequence.addSequenceFeature(sf2); /* diff --git a/src/jalview/io/vamsas/Sequencefeature.java b/src/jalview/io/vamsas/Sequencefeature.java index 61491b2..363f6f1 100644 --- a/src/jalview/io/vamsas/Sequencefeature.java +++ b/src/jalview/io/vamsas/Sequencefeature.java @@ -284,9 +284,39 @@ public class Sequencefeature extends Rangetype 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(); @@ -302,11 +332,7 @@ public class Sequencefeature extends Rangetype 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()); } diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 6ddd828..7261cba 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -263,8 +263,8 @@ public class Uniprot extends DbSourceProxyImpl 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); } } diff --git a/src/jalview/ws/jws2/AADisorderClient.java b/src/jalview/ws/jws2/AADisorderClient.java index 001f6a8..b877d20 100644 --- a/src/jalview/ws/jws2/AADisorderClient.java +++ b/src/jalview/ws/jws2/AADisorderClient.java @@ -20,7 +20,6 @@ */ package jalview.ws.jws2; -import jalview.api.AlignCalcWorkerI; import jalview.api.FeatureColourI; import jalview.bin.Cache; import jalview.datamodel.AlignmentAnnotation; @@ -238,14 +237,14 @@ public class AADisorderClient extends JabawsCalcWorker } 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)) diff --git a/test/jalview/analysis/SeqsetUtilsTest.java b/test/jalview/analysis/SeqsetUtilsTest.java index 11cb10c..ee364c9 100644 --- a/test/jalview/analysis/SeqsetUtilsTest.java +++ b/test/jalview/analysis/SeqsetUtilsTest.java @@ -62,9 +62,8 @@ public class SeqsetUtilsTest 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[] { diff --git a/test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java b/test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java index 4bcf5ab..263844f 100644 --- a/test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java +++ b/test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java @@ -85,18 +85,18 @@ public class FeatureDistanceModelTest 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); diff --git a/test/jalview/datamodel/SequenceFeatureTest.java b/test/jalview/datamodel/SequenceFeatureTest.java index 7b0bc0c..d105cc5 100644 --- a/test/jalview/datamodel/SequenceFeatureTest.java +++ b/test/jalview/datamodel/SequenceFeatureTest.java @@ -137,41 +137,47 @@ public class SequenceFeatureTest // 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"); diff --git a/test/jalview/datamodel/SequenceTest.java b/test/jalview/datamodel/SequenceTest.java index e3e39f7..d7e720e 100644 --- a/test/jalview/datamodel/SequenceTest.java +++ b/test/jalview/datamodel/SequenceTest.java @@ -466,7 +466,7 @@ public class SequenceTest * 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(); diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index 822fcd4..1beca80 100644 --- a/test/jalview/schemes/FeatureColourTest.java +++ b/test/jalview/schemes/FeatureColourTest.java @@ -114,13 +114,15 @@ public class FeatureColourTest 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)); @@ -130,7 +132,9 @@ public class FeatureColourTest // 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)); } -- 1.7.10.2