X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FVamsasAppDatastore.java;h=7608e51542204bedc13fc912f15a8f1da59f6f59;hb=20dd6fc13a9d903dc580939e7f2722bc9b043c4f;hp=6d47a1a657e62746aa28258e9870e45d72c5ab9b;hpb=25aaaa87042b3f507ad4348120df7dd073182759;p=jalview.git diff --git a/src/jalview/io/VamsasAppDatastore.java b/src/jalview/io/VamsasAppDatastore.java index 6d47a1a..7608e51 100644 --- a/src/jalview/io/VamsasAppDatastore.java +++ b/src/jalview/io/VamsasAppDatastore.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -23,6 +23,7 @@ package jalview.io; import jalview.bin.Cache; import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.GraphLine; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; @@ -33,7 +34,9 @@ import jalview.io.vamsas.Datasetsequence; import jalview.io.vamsas.DatastoreItem; import jalview.io.vamsas.DatastoreRegistry; import jalview.io.vamsas.Rangetype; +import jalview.util.MapList; import jalview.util.MessageManager; +import jalview.viewmodel.AlignmentViewport; import java.io.IOException; import java.util.Enumeration; @@ -42,12 +45,35 @@ import java.util.Hashtable; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.Vector; import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; -import uk.ac.vamsas.client.*; -import uk.ac.vamsas.objects.core.*; +import uk.ac.vamsas.client.IClientAppdata; +import uk.ac.vamsas.client.IClientDocument; +import uk.ac.vamsas.client.Vobject; +import uk.ac.vamsas.client.VorbaId; +import uk.ac.vamsas.objects.core.Alignment; +import uk.ac.vamsas.objects.core.AlignmentSequence; +import uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation; +import uk.ac.vamsas.objects.core.AnnotationElement; +import uk.ac.vamsas.objects.core.DataSet; +import uk.ac.vamsas.objects.core.DataSetAnnotations; +import uk.ac.vamsas.objects.core.DbRef; +import uk.ac.vamsas.objects.core.Entry; +import uk.ac.vamsas.objects.core.Glyph; +import uk.ac.vamsas.objects.core.Local; +import uk.ac.vamsas.objects.core.MapType; +import uk.ac.vamsas.objects.core.Mapped; +import uk.ac.vamsas.objects.core.Property; +import uk.ac.vamsas.objects.core.Provenance; +import uk.ac.vamsas.objects.core.RangeAnnotation; +import uk.ac.vamsas.objects.core.RangeType; +import uk.ac.vamsas.objects.core.Seg; +import uk.ac.vamsas.objects.core.Sequence; +import uk.ac.vamsas.objects.core.SequenceType; +import uk.ac.vamsas.objects.core.VAMSAS; import uk.ac.vamsas.objects.utils.Properties; /* @@ -127,7 +153,7 @@ public class VamsasAppDatastore private void buildSkipList() { skipList = new Hashtable(); - AlignFrame[] al = Desktop.getAlignframes(); + AlignFrame[] al = Desktop.getAlignFrames(); for (int f = 0; al != null && f < al.length; f++) { skipList.put(al[f].getViewport().getSequenceSetId(), al[f]); @@ -261,8 +287,8 @@ public class VamsasAppDatastore { try { - jalview.datamodel.AlignmentI jal = av.getAlignment(); - jalview.datamodel.AlignmentI jds = jal.getDataset(); + AlignmentI jal = av.getAlignment(); + AlignmentI jds = jal.getDataset(); boolean nw = false; VAMSAS root = null; // will be resolved based on Dataset Parent. // ///////////////////////////////////////// @@ -514,7 +540,7 @@ public class VamsasAppDatastore // SAVE ANNOTATIONS if (jal.getAlignmentAnnotation() != null) { - jalview.datamodel.AlignmentAnnotation[] aa = jal + AlignmentAnnotation[] aa = jal .getAlignmentAnnotation(); java.util.HashMap AlSeqMaps = new HashMap(); // stores int maps from // alignment columns to @@ -643,7 +669,7 @@ public class VamsasAppDatastore } setAnnotationType(an, aa[i]); - if (aa[i].graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH) + if (aa[i].graph != AlignmentAnnotation.NO_GRAPH) { an.setGraph(true); an.setGroup(Integer.toString(aa[i].graphGroup)); @@ -728,12 +754,12 @@ public class VamsasAppDatastore * @return true if alignment associated with this view will be stored in * document. */ - public boolean alignmentWillBeSkipped(AlignViewport av) + public boolean alignmentWillBeSkipped(AlignmentViewport av) { return (!av.getAlignment().isAligned()); } - private void addToSkipList(AlignViewport av) + private void addToSkipList(AlignmentViewport av) { if (skipList == null) { @@ -1017,7 +1043,7 @@ public class VamsasAppDatastore // of // utf8 // translation - if (alan.graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH) + if (alan.graph != AlignmentAnnotation.NO_GRAPH) { ae.addValue(alan.annotations[a].value); } @@ -1068,8 +1094,10 @@ public class VamsasAppDatastore an.addProperty(Properties.newProperty(THRESHOLD, Properties.FLOATTYPE, "" + alan.getThreshold().value)); if (alan.getThreshold().label != null) + { an.addProperty(Properties.newProperty(THRESHOLD + "Name", Properties.STRINGTYPE, "" + alan.getThreshold().label)); + } } ((DataSet) sref.getV_parent()).addDataSetAnnotations(an); bindjvvobj(alan, an); @@ -1297,7 +1325,7 @@ public class VamsasAppDatastore @Override public JarInputStream getJarInputStream() throws IOException { - jalview.bin.Cache.log + Cache.log .debug("Returning client input stream for Jalview from Vamsas Document."); return new JarInputStream(cappdata.getClientInputStream()); } @@ -1345,7 +1373,7 @@ public class VamsasAppDatastore @Override public JarInputStream getJarInputStream() throws IOException { - jalview.bin.Cache.log + Cache.log .debug("Returning user input stream for Jalview from Vamsas Document."); return new JarInputStream(cappdata.getUserInputStream()); } @@ -1381,12 +1409,12 @@ public class VamsasAppDatastore // sync, // and if any contain more than one view, then remove the one generated by // document update. - AlignViewport views[], av = null; + AlignmentViewport views[], av = null; AlignFrame af = null; Iterator newviews = newAlignmentViews.iterator(); while (newviews.hasNext()) { - av = (AlignViewport) newviews.next(); + av = (AlignmentViewport) newviews.next(); af = Desktop.getAlignFrameFor(av); // TODO implement this : af.getNumberOfViews String seqsetidobj = av.getSequenceSetId(); @@ -1403,7 +1431,8 @@ public class VamsasAppDatastore // to the align frames. boolean gathered = false; String newviewid = null; - AlignedCodonFrame[] mappings = av.getAlignment().getCodonFrames(); + Set mappings = av.getAlignment() + .getCodonFrames(); for (int i = 0; i < views.length; i++) { if (views[i] != av) @@ -1438,7 +1467,7 @@ public class VamsasAppDatastore { // ensure sequence mappings from vamsas document view still // active - if (mappings != null && mappings.length > 0) + if (mappings != null) { jalview.structure.StructureSelectionManager .getStructureSelectionManager(Desktop.instance) @@ -1505,14 +1534,14 @@ public class VamsasAppDatastore } catch (Exception e) { // TODO raise GUI warning if user requests it. - jalview.bin.Cache.log + Cache.log .error("Couldn't update jalview client application data. Giving up - local settings probably lost.", e); } } else { - jalview.bin.Cache.log + Cache.log .error("Couldn't access client application data for vamsas session. This is probably a vamsas client bug."); } } @@ -1641,7 +1670,7 @@ public class VamsasAppDatastore // annotations if (dsSeq == null) { - jalview.bin.Cache.log + Cache.log .warn("Couldn't resolve jalview sequenceI for dataset object reference " + ((Vobject) dataset.getDataSetAnnotations( dsa).getSeqRef(0)).getVorbaId() @@ -1682,9 +1711,9 @@ public class VamsasAppDatastore uk.ac.vamsas.objects.core.Alignment alignment = dataset .getAlignment(al); // TODO check this handles multiple views properly - AlignViewport av = findViewport(alignment); + AlignmentViewport av = findViewport(alignment); - jalview.datamodel.AlignmentI jal = null; + AlignmentI jal = null; if (av != null) { // TODO check that correct alignment object is retrieved when @@ -1726,7 +1755,7 @@ public class VamsasAppDatastore .getAlignmentSequenceAnnotation(); for (int a = 0; a < vasannot.length; a++) { - jalview.datamodel.AlignmentAnnotation asa = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(vasannot[a]); // TODO: + AlignmentAnnotation asa = (AlignmentAnnotation) getvObj2jv(vasannot[a]); // TODO: // 1:many // jalview // alignment @@ -1812,7 +1841,7 @@ public class VamsasAppDatastore for (int j = 0; j < an.length; j++) { - jalview.datamodel.AlignmentAnnotation jan = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(an[j]); + AlignmentAnnotation jan = (AlignmentAnnotation) getvObj2jv(an[j]); if (jan != null) { // update or stay the same. @@ -1956,10 +1985,10 @@ public class VamsasAppDatastore return newAlignmentViews.size(); } - public AlignViewport findViewport(Alignment alignment) + public AlignmentViewport findViewport(Alignment alignment) { - AlignViewport av = null; - AlignViewport[] avs = Desktop + AlignmentViewport av = null; + AlignmentViewport[] avs = Desktop .getViewports((String) getvObj2jv(alignment)); if (avs != null) { @@ -2158,8 +2187,8 @@ public class VamsasAppDatastore * @param annotation * @return unbound jalview alignment annotation object. */ - private jalview.datamodel.AlignmentAnnotation getjAlignmentAnnotation( - jalview.datamodel.AlignmentI jal, + private AlignmentAnnotation getjAlignmentAnnotation( + AlignmentI jal, uk.ac.vamsas.objects.core.RangeAnnotation annotation) { if (annotation == null) @@ -2207,6 +2236,7 @@ public class VamsasAppDatastore Cache.log.warn("Failed to parse threshold property"); } if (val != null) + { if (gl == null) { gl = new GraphLine(val.floatValue(), "", java.awt.Color.black); @@ -2215,16 +2245,19 @@ public class VamsasAppDatastore { gl.value = val.floatValue(); } + } } else if (props[p].getName().equalsIgnoreCase(THRESHOLD + "Name")) { if (gl == null) + { gl = new GraphLine(0, "", java.awt.Color.black); + } gl.label = props[p].getContent(); } } } - jalview.datamodel.AlignmentAnnotation jan = null; + AlignmentAnnotation jan = null; if (a_label == null || a_label.length() == 0) { a_label = annotation.getType(); @@ -2266,14 +2299,14 @@ public class VamsasAppDatastore { if (type == 0) { - type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH; // default + type = AlignmentAnnotation.BAR_GRAPH; // default // type of // value // annotation if (has[HASHPHOB]) { // no hints - so we ensure HPHOB display is like this. - type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH; + type = AlignmentAnnotation.BAR_GRAPH; } } // make bounds and automatic description strings for jalview user's @@ -2345,7 +2378,7 @@ public class VamsasAppDatastore } } } - jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr, + jan = new AlignmentAnnotation(a_label, a_descr, arow, min, max, type); } else @@ -2357,7 +2390,7 @@ public class VamsasAppDatastore // width - if it is not complete, then mark regions on the annotation // row. } - jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr, + jan = new AlignmentAnnotation(a_label, a_descr, arow); jan.setThreshold(null); jan.annotationId = annotation.getVorbaId().toString(); // keep all the @@ -2520,17 +2553,17 @@ public class VamsasAppDatastore * @param default unit for mapped * @return MapList */ - private jalview.util.MapList parsemapType(MapType maprange, int localu, + private MapList parsemapType(MapType maprange, int localu, int mappedu) { - jalview.util.MapList ml = null; + MapList ml = null; int[] localRange = getMapping(maprange.getLocal()); int[] mappedRange = getMapping(maprange.getMapped()); long lu = maprange.getLocal().hasUnit() ? maprange.getLocal().getUnit() : localu; long mu = maprange.getMapped().hasUnit() ? maprange.getMapped() .getUnit() : mappedu; - ml = new jalview.util.MapList(localRange, mappedRange, (int) lu, + ml = new MapList(localRange, mappedRange, (int) lu, (int) mu); return ml; } @@ -2539,15 +2572,15 @@ public class VamsasAppDatastore * initialise a range type object from a set of start/end inclusive intervals * * @param mrt - * @param range + * @param ranges */ - private void initRangeType(RangeType mrt, int[] range) + private void initRangeType(RangeType mrt, List ranges) { - for (int i = 0; i < range.length; i += 2) + for (int[] range : ranges) { Seg vSeg = new Seg(); - vSeg.setStart(range[i]); - vSeg.setEnd(range[i + 1]); + vSeg.setStart(range[0]); + vSeg.setEnd(range[1]); mrt.addSeg(vSeg); } } @@ -2559,7 +2592,7 @@ public class VamsasAppDatastore * @param ml * @param setUnits */ - private void initMapType(MapType maprange, jalview.util.MapList ml, + private void initMapType(MapType maprange, MapList ml, boolean setUnits) { maprange.setLocal(new Local()); @@ -2670,13 +2703,13 @@ public class VamsasAppDatastore return vobj2jv; } - public void storeSequenceMappings(AlignViewport viewport, String title) + public void storeSequenceMappings(AlignmentViewport viewport, String title) throws Exception { - AlignViewport av = viewport; + AlignmentViewport av = viewport; try { - jalview.datamodel.AlignmentI jal = av.getAlignment(); + AlignmentI jal = av.getAlignment(); // ///////////////////////////////////////// // SAVE THE DATASET DataSet dataset = null; @@ -2695,18 +2728,15 @@ public class VamsasAppDatastore } // Store any sequence mappings. - if (av.getAlignment().getCodonFrames() != null - && av.getAlignment().getCodonFrames().length > 0) + Set cframes = av.getAlignment().getCodonFrames(); + if (cframes != null) { - jalview.datamodel.AlignedCodonFrame[] cframes = av.getAlignment() - .getCodonFrames(); - for (int cf = 0; cf < cframes.length; cf++) + for (AlignedCodonFrame acf : cframes) { - if (cframes[cf].getdnaSeqs() != null - && cframes[cf].getdnaSeqs().length > 0) + if (acf.getdnaSeqs() != null && acf.getdnaSeqs().length > 0) { - jalview.datamodel.SequenceI[] dmps = cframes[cf].getdnaSeqs(); - jalview.datamodel.Mapping[] mps = cframes[cf].getProtMappings(); + jalview.datamodel.SequenceI[] dmps = acf.getdnaSeqs(); + jalview.datamodel.Mapping[] mps = acf.getProtMappings(); for (int smp = 0; smp < mps.length; smp++) { uk.ac.vamsas.objects.core.SequenceType mfrom = (SequenceType) getjv2vObj(dmps[smp]);