X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fvamsas%2FSequencefeature.java;h=f8d86d55fef62123725f3d29cb75c9f36439dbaa;hb=3027bfb4b1b13af8686abcd419888e03141bd672;hp=f02fe3ef7ab000fdb582deb3c08301d97b9c4416;hpb=59d682209891099d46b960509907c79e3fb276fe;p=jalview.git diff --git a/src/jalview/io/vamsas/Sequencefeature.java b/src/jalview/io/vamsas/Sequencefeature.java index f02fe3e..f8d86d5 100644 --- a/src/jalview/io/vamsas/Sequencefeature.java +++ b/src/jalview/io/vamsas/Sequencefeature.java @@ -1,26 +1,35 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) - * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.io.vamsas; +import jalview.bin.Cache; +import jalview.datamodel.SequenceFeature; +import jalview.datamodel.SequenceI; +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.DataSet; import uk.ac.vamsas.objects.core.DataSetAnnotations; import uk.ac.vamsas.objects.core.Link; import uk.ac.vamsas.objects.core.Property; @@ -28,13 +37,7 @@ import uk.ac.vamsas.objects.core.Provenance; import uk.ac.vamsas.objects.core.RangeAnnotation; import uk.ac.vamsas.objects.core.Score; import uk.ac.vamsas.objects.core.Seg; -import uk.ac.vamsas.objects.core.Sequence; import uk.ac.vamsas.objects.utils.Properties; -import jalview.bin.Cache; -import jalview.datamodel.SequenceFeature; -import jalview.datamodel.SequenceI; -import jalview.io.VamsasAppDatastore; -import jalview.util.UrlLink; /** * @author JimP @@ -69,6 +72,7 @@ public class Sequencefeature extends Rangetype doJvUpdate(); } + @Override public void addToDocument() { DataSetAnnotations dsa = (DataSetAnnotations) vobj; @@ -87,15 +91,14 @@ public class Sequencefeature extends Rangetype dataset.addDataSetAnnotations(dsa); } + @Override public void addFromDocument() { DataSetAnnotations dsa = (DataSetAnnotations) vobj; if (dsa.getSeqRefCount() != 1) { - Cache.log - .warn("Not binding " - + dsa.getVorbaId() - + " to Sequence Feature - has multiple dataset sequence references."); + Cache.log.warn("Not binding " + dsa.getVorbaId() + + " to Sequence Feature - has multiple dataset sequence references."); return; } jalview.datamodel.SequenceFeature sf = (jalview.datamodel.SequenceFeature) jvobj; @@ -104,6 +107,7 @@ public class Sequencefeature extends Rangetype bindjvvobj(sf, dsa); } + @Override public void conflict() { log.warn("Untested sequencefeature conflict code"); @@ -116,6 +120,7 @@ public class Sequencefeature extends Rangetype addToDocument(); // and create a new feature in the document } + @Override public void updateToDoc() { DataSetAnnotations dsa = (DataSetAnnotations) vobj; @@ -123,8 +128,8 @@ public class Sequencefeature extends Rangetype if (dsa.getSeqRefCount() != 1) { replaceJvObjMapping(feature, null); - Cache.log - .warn("Binding of annotation to jalview feature has changed. Removing binding and recreating."); + Cache.log.warn( + "Binding of annotation to jalview feature has changed. Removing binding and recreating."); doSync(); // re-verify bindings. } else @@ -142,6 +147,7 @@ public class Sequencefeature extends Rangetype } + @Override public void updateFromDoc() { DataSetAnnotations dsa = (DataSetAnnotations) vobj; @@ -150,10 +156,8 @@ public class Sequencefeature extends Rangetype { // conflicting update from document - we cannot map this feature anymore. replaceJvObjMapping(feature, null); - Cache.log - .warn("annotation (" - + dsa.getVorbaId() - + " bound to jalview feature cannot be mapped. Removing binding, deleting feature, and deleting feature."); + Cache.log.warn("annotation (" + dsa.getVorbaId() + + " bound to jalview feature cannot be mapped. Removing binding, deleting feature, and deleting feature."); // - consider deleting the feature ? dsSeq.deleteFeature(feature); // doSync(); @@ -194,19 +198,18 @@ public class Sequencefeature extends Rangetype vSeg.setInclusive(true); if (dsa.getSegCount() > 1) { - Cache.log - .debug("About to destroy complex annotation in vamsas document mapped to sequence feature (" + Cache.log.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) { for (int i = 0, iSize = feature.links.size(); i < iSize; i++) { - String link = (String) feature.links.elementAt(i); + String link = feature.links.elementAt(i); UrlLink ulink = new UrlLink(link); if (ulink.isValid()) { @@ -219,21 +222,20 @@ public class Sequencefeature extends Rangetype } } dsa.setGroup(feature.getFeatureGroup()); - if (feature.getScore() != Float.NaN) + 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")) { @@ -250,7 +252,8 @@ public class Sequencefeature extends Rangetype else if (vlu instanceof Integer) { valid = true; - nprop.setType(uk.ac.vamsas.objects.utils.Properties.INTEGERTYPE); + nprop.setType( + uk.ac.vamsas.objects.utils.Properties.INTEGERTYPE); } else if (vlu instanceof Float) { @@ -278,9 +281,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(); @@ -296,11 +329,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()); } @@ -322,7 +351,7 @@ public class Sequencefeature extends Rangetype { try { - val = new Boolean(p.getContent()); + val = Boolean.valueOf(p.getContent()); } catch (Exception e) { } @@ -331,7 +360,7 @@ public class Sequencefeature extends Rangetype { try { - val = new Float(p.getContent()); + val = Float.valueOf(p.getContent()); } catch (Exception e) { @@ -341,7 +370,7 @@ public class Sequencefeature extends Rangetype { try { - val = new Integer(p.getContent()); + val = Integer.valueOf(p.getContent()); } catch (Exception e) { }