X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FVamsasAppDatastore.java;h=6293a1b39c67d134f02b2109f4d1bdbc8aef1c07;hb=5720f2cea034f014f366886b3cb9a170a909e988;hp=108bcb7b9db1e127d8e8ef117b5c03090d9e9541;hpb=153dd62dc91da13ae732600e6ea55ddbe15eab39;p=jalview.git diff --git a/src/jalview/io/VamsasAppDatastore.java b/src/jalview/io/VamsasAppDatastore.java index 108bcb7..6293a1b 100644 --- a/src/jalview/io/VamsasAppDatastore.java +++ b/src/jalview/io/VamsasAppDatastore.java @@ -1,30 +1,29 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6) - * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 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; import jalview.bin.Cache; import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.AlignmentView; -import jalview.datamodel.DBRefEntry; import jalview.datamodel.GraphLine; -import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.gui.AlignFrame; import jalview.gui.AlignViewport; @@ -34,7 +33,7 @@ import jalview.io.vamsas.Datasetsequence; import jalview.io.vamsas.DatastoreItem; import jalview.io.vamsas.DatastoreRegistry; import jalview.io.vamsas.Rangetype; -import jalview.util.UrlLink; +import jalview.util.MessageManager; import java.io.IOException; import java.util.Enumeration; @@ -42,6 +41,7 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.IdentityHashMap; import java.util.Iterator; +import java.util.List; import java.util.Vector; import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; @@ -51,14 +51,14 @@ import uk.ac.vamsas.objects.core.*; import uk.ac.vamsas.objects.utils.Properties; /* - * + * * static { * org.exolab.castor.util.LocalConfiguration.getInstance().getProperties().setProperty( * "org.exolab.castor.serializer", "org.apache.xml.serialize.XMLSerilazizer"); } - * + * */ /* - * TODO: check/verify consistency for vamsas sync with group associated alignment annotation + * TODO: check/verify consistency for vamsas sync with group associated alignment annotation */ public class VamsasAppDatastore { @@ -224,8 +224,7 @@ public class VamsasAppDatastore { Cache.log.debug( "Warning? Overwriting existing vamsas id binding for " - + vobj.getVorbaId(), new Exception( - "Overwriting vamsas id binding.")); + + vobj.getVorbaId(), new Exception(MessageManager.getString("exception.overwriting_vamsas_id_binding"))); } else if (jv2vobj.containsKey(jvobj) && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId())) @@ -312,8 +311,7 @@ public class VamsasAppDatastore if (vbound.getV_parent() != null && dataset != vbound.getV_parent()) { - throw new Error( - "IMPLEMENTATION ERROR: Cannot map an alignment of sequences from different datasets into a single alignment in the vamsas document."); + throw new Error(MessageManager.getString("error.implementation_error_cannot_map_alignment_sequences")); // This occurs because the dataset for the alignment we are // trying to } @@ -424,8 +422,8 @@ public class VamsasAppDatastore { boolean modified = false; // check existing sequences in local and in document. - Vector docseqs = new Vector(alignment - .getAlignmentSequenceAsReference()); + Vector docseqs = new Vector( + alignment.getAlignmentSequenceAsReference()); for (int i = 0; i < jal.getHeight(); i++) { modified |= syncToAlignmentSequence(jal.getSequenceAt(i), @@ -546,12 +544,8 @@ public class VamsasAppDatastore else { // first find the alignment sequence to associate this with. - SequenceI jvalsq = null; - Enumeration jval = av.getAlignment().getSequences() - .elements(); - while (jval.hasMoreElements()) + for (SequenceI jvalsq : av.getAlignment().getSequences()) { - jvalsq = (SequenceI) jval.nextElement(); // saveDatasetSequenceAnnotation(AlSeqMaps,(uk.ac.vamsas.objects.core.Sequence) // sref, aa[i]); if (jvalsq.getDatasetSequence() == aa[i].sequenceRef) @@ -633,11 +627,9 @@ public class VamsasAppDatastore if (aa[i].annotations[a].secondaryStructure != ' ') { Glyph ss = new Glyph(); - ss - .setDict(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE); - ss - .setContent(String - .valueOf(aa[i].annotations[a].secondaryStructure)); + ss.setDict(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE); + ss.setContent(String + .valueOf(aa[i].annotations[a].secondaryStructure)); ae.addGlyph(ss); } an.addAnnotationElement(ae); @@ -657,10 +649,8 @@ public class VamsasAppDatastore an.setGroup(Integer.toString(aa[i].graphGroup)); if (aa[i].threshold != null && aa[i].threshold.displayed) { - an - .addProperty(Properties.newProperty(THRESHOLD, - Properties.FLOATTYPE, "" - + aa[i].threshold.value)); + an.addProperty(Properties.newProperty(THRESHOLD, + Properties.FLOATTYPE, "" + aa[i].threshold.value)); if (aa[i].threshold.label != null) { an.addProperty(Properties.newProperty(THRESHOLD @@ -708,8 +698,8 @@ public class VamsasAppDatastore { TreePanel tp = (TreePanel) frames[t]; - if (tp.getViewPort().getSequenceSetId().equals( - av.getSequenceSetId())) + if (tp.getViewPort().getSequenceSetId() + .equals(av.getSequenceSetId())) { DatastoreItem vtree = new jalview.io.vamsas.Tree(this, tp, jal, alignment); @@ -888,7 +878,7 @@ public class VamsasAppDatastore * creates/syncs the jvalsq from the alignment sequence */ private boolean syncFromAlignmentSequence(AlignmentSequence valseq, - char valGapchar, char gapChar, Vector dsseqs) + char valGapchar, char gapChar, List dsseqs) { boolean modal = false; @@ -936,8 +926,8 @@ public class VamsasAppDatastore else { alseq = new jalview.datamodel.Sequence(valseq.getName(), valseq - .getSequence().replace(valGapchar, gapChar), (int) valseq - .getStart(), (int) valseq.getEnd()); + .getSequence().replace(valGapchar, gapChar), + (int) valseq.getStart(), (int) valseq.getEnd()); Vobject datsetseq = (Vobject) valseq.getRefid(); if (datsetseq != null) @@ -1037,8 +1027,7 @@ public class VamsasAppDatastore { // we only write an annotation where it really exists. Glyph ss = new Glyph(); - ss - .setDict(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE); + ss.setDict(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE); ss.setContent(String .valueOf(alan.annotations[a].secondaryStructure)); ae.addGlyph(ss); @@ -1265,7 +1254,7 @@ public class VamsasAppDatastore /** * list of alignment views created when updating Jalview from document. */ - private Vector newAlignmentViews = new Vector(); + private final Vector newAlignmentViews = new Vector(); /** * update local jalview view settings from the stored appdata (if any) @@ -1297,6 +1286,7 @@ public class VamsasAppDatastore jalview.util.jarInputStreamProvider jprovider = new jalview.util.jarInputStreamProvider() { + @Override public String getFilename() { @@ -1304,6 +1294,7 @@ public class VamsasAppDatastore return "Jalview Vamsas Document Client Data"; } + @Override public JarInputStream getJarInputStream() throws IOException { jalview.bin.Cache.log @@ -1343,6 +1334,7 @@ public class VamsasAppDatastore jalview.util.jarInputStreamProvider jarstream = new jalview.util.jarInputStreamProvider() { + @Override public String getFilename() { @@ -1350,6 +1342,7 @@ public class VamsasAppDatastore return "Jalview Vamsas Document User Data"; } + @Override public JarInputStream getJarInputStream() throws IOException { jalview.bin.Cache.log @@ -1448,7 +1441,8 @@ public class VamsasAppDatastore if (mappings != null && mappings.length > 0) { jalview.structure.StructureSelectionManager - .getStructureSelectionManager().addMappings(mappings); + .getStructureSelectionManager(Desktop.instance) + .addMappings(mappings); } } } @@ -1477,9 +1471,9 @@ public class VamsasAppDatastore Object vobject = jv2vobj.remove(oldjvobject); if (vobject == null) { - throw new Error( - "IMPLEMENTATION ERROR: old jalview object is not bound ! (" - + oldjvobject + ")"); + // NOTE: this happens if user deletes object in one session then updates + // from another client + throw new Error(MessageManager.formatMessage("error.implementation_error_old_jalview_object_not_bound", new String[]{oldjvobject.toString()})); } if (newjvobject != null) { @@ -1512,8 +1506,7 @@ public class VamsasAppDatastore { // TODO raise GUI warning if user requests it. jalview.bin.Cache.log - .error( - "Couldn't update jalview client application data. Giving up - local settings probably lost.", + .error("Couldn't update jalview client application data. Giving up - local settings probably lost.", e); } } @@ -1579,7 +1572,7 @@ public class VamsasAppDatastore // ///LOAD DATASET DataSet dataset = root.getDataSet(_ds); int i, iSize = dataset.getSequenceCount(); - Vector dsseqs; + List dsseqs; jalview.datamodel.Alignment jdataset = (jalview.datamodel.Alignment) getvObj2jv(dataset); int jremain = 0; if (jdataset == null) @@ -1626,8 +1619,8 @@ public class VamsasAppDatastore SequenceI[] seqs = new SequenceI[dsseqs.size()]; for (i = 0, iSize = dsseqs.size(); i < iSize; i++) { - seqs[i] = (SequenceI) dsseqs.elementAt(i); - dsseqs.setElementAt(null, i); + seqs[i] = dsseqs.get(i); + dsseqs.set(i, null); } jdataset = new jalview.datamodel.Alignment(seqs); Cache.log.debug("New vamsas dataset imported into jalview."); @@ -1720,8 +1713,7 @@ public class VamsasAppDatastore AlignmentSequence valseq = alignment.getAlignmentSequence(i); jalview.datamodel.Sequence alseq = (jalview.datamodel.Sequence) getvObj2jv(valseq); if (syncFromAlignmentSequence(valseq, valGapchar, gapChar, - dsseqs) - && alseq != null) + dsseqs) && alseq != null) { // updated to sequence from the document @@ -1789,8 +1781,8 @@ public class VamsasAppDatastore SequenceI[] seqs = new SequenceI[dsseqs.size()]; for (i = 0, iSize = dsseqs.size(); i < iSize; i++) { - seqs[i] = (SequenceI) dsseqs.elementAt(i); - dsseqs.setElementAt(null, i); + seqs[i] = dsseqs.get(i); + dsseqs.set(i, null); } jal = new jalview.datamodel.Alignment(seqs); Cache.log.debug("New vamsas alignment imported into jalview " @@ -1867,8 +1859,10 @@ public class VamsasAppDatastore .toString()); av = alignFrame.getViewport(); newAlignmentViews.addElement(av); - String title = alignment.getProvenance().getEntry( - alignment.getProvenance().getEntryCount() - 1) + String title = alignment + .getProvenance() + .getEntry( + alignment.getProvenance().getEntryCount() - 1) .getAction(); if (alignment.getPropertyCount() > 0) { @@ -2059,16 +2053,14 @@ public class VamsasAppDatastore { if (glyphs[g] .getDict() - .equals( - uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE)) + .equals(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE)) { ss = glyphs[g].getContent(); AeContent[HASSECSTR] = true; } else if (glyphs[g] .getDict() - .equals( - uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_HD_HYDRO)) + .equals(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_HD_HYDRO)) { Cache.log.debug("ignoring hydrophobicity glyph marker."); AeContent[HASHPHOB] = true; @@ -2107,14 +2099,14 @@ public class VamsasAppDatastore if (colour == null) { anot[row][pos] = new jalview.datamodel.Annotation( - (dc != null) ? dc : "", desc, (ss != null) ? ss - .charAt(0) : ' ', val); + (dc != null) ? dc : "", desc, + (ss != null) ? ss.charAt(0) : ' ', val); } else { anot[row][pos] = new jalview.datamodel.Annotation( - (dc != null) ? dc : "", desc, (ss != null) ? ss - .charAt(0) : ' ', val, colour); + (dc != null) ? dc : "", desc, + (ss != null) ? ss.charAt(0) : ' ', val, colour); } } else @@ -2423,8 +2415,7 @@ public class VamsasAppDatastore int[] se = null; if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0) { - throw new Error( - "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + throw new Error(MessageManager.getString("error.invalid_vamsas_rangetype_cannot_resolve_lists")); } if (dseta.getSegCount() > 0) { @@ -2482,8 +2473,7 @@ public class VamsasAppDatastore int[] se = null; if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0) { - throw new Error( - "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!"); + throw new Error(MessageManager.getString("error.invalid_vamsas_rangetype_cannot_resolve_lists")); } if (dseta.getSegCount() > 0) { @@ -2739,8 +2729,7 @@ public class VamsasAppDatastore } } catch (Exception e) { - throw new Exception("Couldn't store sequence mappings for " + title, - e); + throw new Exception(MessageManager.formatMessage("exception.couldnt_store_sequence_mappings", new String[]{title}),e); } }