X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fvamsas%2FSequencefeature.java;h=363f6f14345799e72d79916091d0d1e06b99fd70;hb=ffa5c07d90b4a933762a5d9faa0578c11693d63a;hp=ffc99989b69c824db18e3c2e5c082252c78e28c8;hpb=d5e68080b056c94c485cfbd46adebd57cad8da76;p=jalview.git diff --git a/src/jalview/io/vamsas/Sequencefeature.java b/src/jalview/io/vamsas/Sequencefeature.java index ffc9998..363f6f1 100644 --- a/src/jalview/io/vamsas/Sequencefeature.java +++ b/src/jalview/io/vamsas/Sequencefeature.java @@ -27,6 +27,7 @@ import jalview.io.VamsasAppDatastore; import jalview.util.UrlLink; import java.util.Enumeration; +import java.util.Iterator; import java.util.Vector; import uk.ac.vamsas.objects.core.DataSetAnnotations; @@ -71,6 +72,7 @@ public class Sequencefeature extends Rangetype doJvUpdate(); } + @Override public void addToDocument() { DataSetAnnotations dsa = (DataSetAnnotations) vobj; @@ -89,6 +91,7 @@ public class Sequencefeature extends Rangetype dataset.addDataSetAnnotations(dsa); } + @Override public void addFromDocument() { DataSetAnnotations dsa = (DataSetAnnotations) vobj; @@ -106,6 +109,7 @@ public class Sequencefeature extends Rangetype bindjvvobj(sf, dsa); } + @Override public void conflict() { log.warn("Untested sequencefeature conflict code"); @@ -118,6 +122,7 @@ public class Sequencefeature extends Rangetype addToDocument(); // and create a new feature in the document } + @Override public void updateToDoc() { DataSetAnnotations dsa = (DataSetAnnotations) vobj; @@ -144,6 +149,7 @@ public class Sequencefeature extends Rangetype } + @Override public void updateFromDoc() { DataSetAnnotations dsa = (DataSetAnnotations) vobj; @@ -200,8 +206,7 @@ public class Sequencefeature extends Rangetype .debug("About to destroy complex annotation in vamsas document mapped to sequence feature (" + dsa.getVorbaId() + ")"); } - dsa.setSeg(new Seg[] - { vSeg }); + dsa.setSeg(new Seg[] { vSeg }); dsa.setDescription(feature.getDescription()); dsa.setStatus(feature.getStatus()); if (feature.links != null && feature.links.size() > 0) @@ -224,18 +229,17 @@ public class Sequencefeature extends Rangetype if (!Float.isNaN(feature.getScore())) { Score fscore = new Score(); - dsa.setScore(new Score[] - { fscore }); + dsa.setScore(new Score[] { fscore }); fscore.setContent(feature.getScore()); fscore.setName(feature.getType()); } if (feature.otherDetails != null) { - Enumeration iter = feature.otherDetails.keys(); + Iterator iter = feature.otherDetails.keySet().iterator(); Vector props = dsa.getPropertyAsReference(); - while (iter.hasMoreElements()) + while (iter.hasNext()) { - String key = (String) iter.nextElement(); + String key = iter.next(); if (!key.equalsIgnoreCase("score") && !key.equalsIgnoreCase("status")) { @@ -280,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(); @@ -298,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()); }