/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
- * 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.
*
* 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 <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.io;
import jalview.io.vamsas.DatastoreItem;
import jalview.io.vamsas.DatastoreRegistry;
import jalview.io.vamsas.Rangetype;
+import jalview.project.Jalview2XML;
+import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
+
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
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;
/*
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]);
Vobject obj = getjv2vObj(seqsetidobj);
if (obj != null && !(obj instanceof Alignment))
{
- Cache.log
- .warn("IMPLEMENTATION ERROR?: Unexpected mapping for unmapped jalview string object content:"
+ Cache.log.warn(
+ "IMPLEMENTATION ERROR?: Unexpected mapping for unmapped jalview string object content:"
+ seqsetidobj + " to object " + obj);
}
return obj;
if (Cache.log.isDebugEnabled())
{
- Cache.log.debug("Returning null VorbaID binding for jalview object "
- + jvobj);
+ Cache.log.debug(
+ "Returning null VorbaID binding for jalview object " + jvobj);
}
return null;
}
if (id == null)
{
id = cdoc.registerObject(vobj);
- Cache.log
- .debug("Registering new object and returning null for getvObj2jv");
+ Cache.log.debug(
+ "Registering new object and returning null for getvObj2jv");
return null;
}
if (vobj2jv.containsKey(vobj.getVorbaId()))
{
Cache.log.error("Failed to get id for "
+ (vobj.isRegisterable() ? "registerable"
- : "unregisterable") + " object " + vobj);
+ : "unregisterable")
+ + " object " + vobj);
}
}
{
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()))
{
Cache.log.debug(
"Warning? Overwriting existing jalview object binding for "
- + jvobj, new Exception(
- "Overwriting jalview object binding."));
+ + jvobj,
+ new Exception("Overwriting jalview object binding."));
}
/*
* Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id "
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
}
// flag.
// this *will* break when alignment contains both nucleotide and amino
// acid sequences.
- String dict = jal.isNucleotide() ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
+ String dict = jal.isNucleotide()
+ ? uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_NA
: uk.ac.vamsas.objects.utils.SymbolDictionary.STANDARD_AA;
Vector dssmods = new Vector();
for (int i = 0; i < jal.getHeight(); i++)
// referenced
// sequences
// to dataset.
- Datasetsequence dssync = new jalview.io.vamsas.Datasetsequence(
- this, sq, dict, dataset);
+ Datasetsequence dssync = new jalview.io.vamsas.Datasetsequence(this,
+ sq, dict, dataset);
sequence = (Sequence) dssync.getVobj();
if (dssync.getModified())
{
dssmods.addElement(sequence);
}
- ;
}
if (dssmods.size() > 0)
{
else
{
// always prepare to clone the alignment
- boolean alismod = av.isUndoRedoHashModified((long[]) alignRDHash
- .get(av.getSequenceSetId()));
+ boolean alismod = av.isUndoRedoHashModified(
+ (long[]) alignRDHash.get(av.getSequenceSetId()));
// todo: verify and update mutable alignment props.
// TODO: Use isLocked methods
if (alignment.getModifiable() == null
{
// removeValignmentSequences(alignment, docseqs);
docseqs.removeAllElements();
- System.out
- .println("Sequence deletion from alignment is not implemented.");
+ System.out.println(
+ "Sequence deletion from alignment is not implemented.");
}
if (modified)
// unbind alignment from view.
// create new binding and new alignment.
// mark trail on new alignment as being derived from old ?
- System.out
- .println("update edited alignment to new alignment in document.");
+ System.out.println(
+ "update edited alignment to new alignment in document.");
}
}
// ////////////////////////////////////////////
// SAVE Alignment Sequence Features
- for (int i = 0, iSize = alignment.getAlignmentSequenceCount(); i < iSize; i++)
+ for (int i = 0, iSize = alignment
+ .getAlignmentSequenceCount(); i < iSize; i++)
{
AlignmentSequence valseq;
- SequenceI alseq = (SequenceI) getvObj2jv(valseq = alignment
- .getAlignmentSequence(i));
+ SequenceI alseq = (SequenceI) getvObj2jv(
+ valseq = alignment.getAlignmentSequence(i));
if (alseq != null && alseq.getSequenceFeatures() != null)
{
/*
if (aa[i].groupRef != null)
{
// TODO: store any group associated annotation references
- Cache.log
- .warn("Group associated sequence annotation is not stored in VAMSAS document.");
+ Cache.log.warn(
+ "Group associated sequence annotation is not stored in VAMSAS document.");
continue;
}
if (aa[i].sequenceRef != null)
(AlignmentSequence) alsref, aa[i]);
break;
}
- ;
}
}
}
else
{
// add Alignment Annotation
- uk.ac.vamsas.objects.core.AlignmentAnnotation an = (uk.ac.vamsas.objects.core.AlignmentAnnotation) getjv2vObj(aa[i]);
+ uk.ac.vamsas.objects.core.AlignmentAnnotation an = (uk.ac.vamsas.objects.core.AlignmentAnnotation) getjv2vObj(
+ aa[i]);
if (an == null)
{
an = new uk.ac.vamsas.objects.core.AlignmentAnnotation();
ae = new AnnotationElement();
ae.setDescription(aa[i].annotations[a].description);
ae.addGlyph(new Glyph());
- ae.getGlyph(0).setContent(
- aa[i].annotations[a].displayCharacter); // assume
+ ae.getGlyph(0)
+ .setContent(aa[i].annotations[a].displayCharacter); // assume
// jax-b
// takes
// care
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);
if (aa[i].threshold != null && aa[i].threshold.displayed)
{
an.addProperty(Properties.newProperty(THRESHOLD,
- Properties.FLOATTYPE, "" + aa[i].threshold.value));
+ Properties.FLOATTYPE,
+ "" + aa[i].threshold.value));
if (aa[i].threshold.label != null)
{
- an.addProperty(Properties.newProperty(THRESHOLD
- + "Name", Properties.STRINGTYPE, ""
- + aa[i].threshold.label));
+ an.addProperty(Properties.newProperty(
+ THRESHOLD + "Name", Properties.STRINGTYPE,
+ "" + aa[i].threshold.label));
}
}
}
// LOCK METHODS)
{
// verify annotation - update (perhaps)
- Cache.log
- .info("update alignment sequence annotation. not yet implemented.");
+ Cache.log.info(
+ "update alignment sequence annotation. not yet implemented.");
}
else
{
// verify annotation - update (perhaps)
- Cache.log
- .info("updated alignment sequence annotation added.");
+ Cache.log.info(
+ "updated alignment sequence annotation added.");
}
}
}
// /SAVE THE TREES
// /////////////////////////////////
// FIND ANY ASSOCIATED TREES
- if (Desktop.desktop != null)
+ if (Desktop.getDesktopPane() != null)
{
- javax.swing.JInternalFrame[] frames = Desktop.instance
+ javax.swing.JInternalFrame[] frames = Desktop.getInstance()
.getAllFrames();
for (int t = 0; t < frames.length; t++)
* @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)
{
* @param alignment
* @param docseqs
*/
- private void removeValignmentSequences(Alignment alignment, Vector docseqs)
+ private void removeValignmentSequences(Alignment alignment,
+ Vector docseqs)
{
// delete these from document. This really needs to be a generic document
// API function derived by CASTOR.
Enumeration en = docseqs.elements();
while (en.hasMoreElements())
{
- alignment.removeAlignmentSequence((AlignmentSequence) en
- .nextElement());
+ alignment.removeAlignmentSequence(
+ (AlignmentSequence) en.nextElement());
}
- Entry pe = addProvenance(alignment.getProvenance(), "Removed "
- + docseqs.size() + " sequences");
+ Entry pe = addProvenance(alignment.getProvenance(),
+ "Removed " + docseqs.size() + " sequences");
en = alignment.enumerateAlignmentAnnotation();
Vector toremove = new Vector();
while (en.hasMoreElements())
en = toremove.elements();
while (en.hasMoreElements())
{
- alignment
- .removeAlignmentAnnotation((uk.ac.vamsas.objects.core.AlignmentAnnotation) en
+ alignment.removeAlignmentAnnotation(
+ (uk.ac.vamsas.objects.core.AlignmentAnnotation) en
.nextElement());
}
// TODO: search through alignment annotations to remove any references to
modal = true;
alseq.setName(jvalsq.getName());
}
- if (jvalsq.getDescription() != null
- && (alseq.getDescription() == null || !jvalsq.getDescription()
- .equals(alseq.getDescription())))
+ if (jvalsq.getDescription() != null && (alseq.getDescription() == null
+ || !jvalsq.getDescription().equals(alseq.getDescription())))
{
modal = true;
alseq.setDescription(jvalsq.getDescription());
}
if (getjv2vObj(jvalsq.getDatasetSequence()) == null)
{
- Cache.log
- .warn("Serious Implementation error - Unbound dataset sequence in alignment: "
+ Cache.log.warn(
+ "Serious Implementation error - Unbound dataset sequence in alignment: "
+ jvalsq.getDatasetSequence());
}
alseq.setRefid(getjv2vObj(jvalsq.getDatasetSequence()));
|| !valseq.getSequence().equals(alseq.getSequenceAsString()))
{
// this might go *horribly* wrong
- alseq.setSequence(new String(valseq.getSequence()).replace(
- valGapchar, gapChar));
+ alseq.setSequence(new String(valseq.getSequence())
+ .replace(valGapchar, gapChar));
alseq.setStart((int) valseq.getStart());
alseq.setEnd((int) valseq.getEnd());
modal = true;
modal = true;
alseq.setName(valseq.getName());
}
- if (alseq.getDescription() == null
- || (valseq.getDescription() != null && !alseq
- .getDescription().equals(valseq.getDescription())))
+ if (alseq.getDescription() == null || (valseq.getDescription() != null
+ && !alseq.getDescription().equals(valseq.getDescription())))
{
alseq.setDescription(valseq.getDescription());
modal = true;
}
if (modal && Cache.log.isDebugEnabled())
{
- Cache.log.debug("Updating apparently edited sequence "
- + alseq.getName());
+ Cache.log.debug(
+ "Updating apparently edited sequence " + alseq.getName());
}
}
else
{
- alseq = new jalview.datamodel.Sequence(valseq.getName(), valseq
- .getSequence().replace(valGapchar, gapChar),
+ alseq = new jalview.datamodel.Sequence(valseq.getName(),
+ valseq.getSequence().replace(valGapchar, gapChar),
(int) valseq.getStart(), (int) valseq.getEnd());
Vobject datsetseq = (Vobject) valseq.getRefid();
// inherit description line from dataset.
if (alseq.getDatasetSequence().getDescription() != null)
{
- alseq.setDescription(alseq.getDatasetSequence()
- .getDescription());
+ alseq.setDescription(
+ alseq.getDatasetSequence().getDescription());
}
}
// if
}
else
{
- Cache.log
- .error("Invalid dataset sequence id (null) for alignment sequence "
+ Cache.log.error(
+ "Invalid dataset sequence id (null) for alignment sequence "
+ valseq.getVorbaId());
}
bindjvvobj(alseq, valseq);
{
// 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.setContent(String
- .valueOf(alan.annotations[a].secondaryStructure));
+ ss.setDict(
+ uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE);
+ ss.setContent(
+ String.valueOf(alan.annotations[a].secondaryStructure));
ae.addGlyph(ss);
}
an.addAnnotationElement(ae);
// uk.ac.vamsas.
// objects.core.AlignmentSequence alsref = (uk.ac.vamsas.
// objects.core.AlignmentSequence) sref;
- uk.ac.vamsas.objects.core.DataSetAnnotations an = (uk.ac.vamsas.objects.core.DataSetAnnotations) getjv2vObj(alan);
+ uk.ac.vamsas.objects.core.DataSetAnnotations an = (uk.ac.vamsas.objects.core.DataSetAnnotations) getjv2vObj(
+ alan);
int[] gapMap = getGapMap(AlSeqMaps, alan);
if (an == null)
{
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);
else
{
// verify existing alignment sequence annotation is up to date
- System.out
- .println("make new alignment dataset sequence annotation if modification has happened.");
+ System.out.println(
+ "make new alignment dataset sequence annotation if modification has happened.");
}
}
// uk.ac.vamsas.
// objects.core.AlignmentSequence alsref = (uk.ac.vamsas.
// objects.core.AlignmentSequence) sref;
- uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation an = (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) getjv2vObj(alan);
+ uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation an = (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) getjv2vObj(
+ alan);
int[] gapMap = getGapMap(AlSeqMaps, alan);
if (an == null)
{
else
{
// verify existing alignment sequence annotation is up to date
- System.out
- .println("make new alignment sequence annotation if modification has happened.");
+ System.out.println(
+ "make new alignment sequence annotation if modification has happened.");
}
}
}
end = start;
start = t;
}
- return new int[]
- { start, end, pol < 0 ? 1 : 0 };
+ return new int[] { start, end, pol < 0 ? 1 : 0 };
}
/**
// client data is shared over all app clients
try
{
- jalview.gui.Jalview2XML fromxml = new jalview.gui.Jalview2XML();
+ // jalview.gui.Jalview2XML fromxml = new jalview.gui.Jalview2XML();
+ Jalview2XML fromxml = new Jalview2XML();
fromxml.attemptversion1parse = false;
fromxml.setUniqueSetSuffix("");
fromxml.setObjectMappingTables(vobj2jv, jv2vobj); // mapKeysToString
@Override
public JarInputStream getJarInputStream() throws IOException
{
- jalview.bin.Cache.log
- .debug("Returning client input stream for Jalview from Vamsas Document.");
+ jalview.bin.Cache.log.debug(
+ "Returning client input stream for Jalview from Vamsas Document.");
return new JarInputStream(cappdata.getClientInputStream());
}
};
if (dojvsync)
{
- fromxml.LoadJalviewAlign(jprovider);
+ fromxml.loadJalviewAlign(jprovider);
}
} catch (Exception e)
{
// user data overrides data shared over all app clients ?
try
{
- jalview.gui.Jalview2XML fromxml = new jalview.gui.Jalview2XML();
+ Jalview2XML fromxml = new Jalview2XML();
fromxml.attemptversion1parse = false;
fromxml.setUniqueSetSuffix("");
fromxml.setSkipList(skipList);
@Override
public JarInputStream getJarInputStream() throws IOException
{
- jalview.bin.Cache.log
- .debug("Returning user input stream for Jalview from Vamsas Document.");
+ jalview.bin.Cache.log.debug(
+ "Returning user input stream for Jalview from Vamsas Document.");
return new JarInputStream(cappdata.getUserInputStream());
}
};
if (dojvsync)
{
- fromxml.LoadJalviewAlign(jarstream);
+ fromxml.loadJalviewAlign(jarstream);
}
} catch (Exception e)
{
// 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();
views = Desktop.getViewports(seqsetidobj);
- Cache.log.debug("Found "
- + (views == null ? " no " : "" + views.length)
- + " views for '" + av.getSequenceSetId() + "'");
+ Cache.log
+ .debug("Found " + (views == null ? " no " : "" + views.length)
+ + " views for '" + av.getSequenceSetId() + "'");
if (views.length > 1)
{
// we need to close the original document view.
// to the align frames.
boolean gathered = false;
String newviewid = null;
- AlignedCodonFrame[] mappings = av.getAlignment().getCodonFrames();
+ List<AlignedCodonFrame> mappings = av.getAlignment()
+ .getCodonFrames();
for (int i = 0; i < views.length; i++)
{
if (views[i] != av)
{
// ensure sequence mappings from vamsas document view still
// active
- if (mappings != null && mappings.length > 0)
+ if (mappings != null)
{
- jalview.structure.StructureSelectionManager
- .getStructureSelectionManager(Desktop.instance)
- .addMappings(mappings);
+ Desktop.getStructureSelectionManager()
+ .registerMappings(mappings);
}
}
}
{
// NOTE: this happens if user deletes object in one session then updates
// from another client
- throw new Error(
- "IMPLEMENTATION ERROR: old jalview object is not bound ! ("
- + oldjvobject + ")");
+ throw new Error(MessageManager.formatMessage(
+ "error.implementation_error_old_jalview_object_not_bound",
+ new String[]
+ { oldjvobject.toString() }));
}
if (newjvobject != null)
{
{
try
{
- jalview.gui.Jalview2XML jxml = new jalview.gui.Jalview2XML();
+ Jalview2XML jxml = new Jalview2XML();
jxml.setObjectMappingTables(mapKeysToString(vobj2jv),
mapValuesToString(jv2vobj));
jxml.setSkipList(skipList);
if (dojvsync)
{
- jxml.SaveState(new JarOutputStream(cappdata
- .getClientOutputStream()));
+ jxml.saveState(
+ new JarOutputStream(cappdata.getClientOutputStream()));
}
} catch (Exception e)
{
// 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.",
- e);
+ jalview.bin.Cache.log.error(
+ "Couldn't update jalview client application data. Giving up - local settings probably lost.",
+ e);
}
}
else
{
- jalview.bin.Cache.log
- .error("Couldn't access client application data for vamsas session. This is probably a vamsas client bug.");
+ jalview.bin.Cache.log.error(
+ "Couldn't access client application data for vamsas session. This is probably a vamsas client bug.");
}
}
DataSet dataset = root.getDataSet(_ds);
int i, iSize = dataset.getSequenceCount();
List<SequenceI> dsseqs;
- jalview.datamodel.Alignment jdataset = (jalview.datamodel.Alignment) getvObj2jv(dataset);
+ jalview.datamodel.Alignment jdataset = (jalview.datamodel.Alignment) getvObj2jv(
+ dataset);
int jremain = 0;
if (jdataset == null)
{
// add any new dataset sequence feature annotations
if (dataset.getDataSetAnnotations() != null)
{
- for (int dsa = 0; dsa < dataset.getDataSetAnnotationsCount(); dsa++)
+ for (int dsa = 0; dsa < dataset
+ .getDataSetAnnotationsCount(); dsa++)
{
DataSetAnnotations dseta = dataset.getDataSetAnnotations(dsa);
// TODO: deal with group annotation on datset sequences.
if (dseta.getSeqRefCount() == 1)
{
- SequenceI dsSeq = (SequenceI) getvObj2jv((Vobject) dseta
- .getSeqRef(0)); // TODO: deal with group dataset
+ SequenceI dsSeq = (SequenceI) getvObj2jv(
+ (Vobject) dseta.getSeqRef(0)); // TODO: deal with group
+ // dataset
// annotations
if (dsSeq == null)
{
- jalview.bin.Cache.log
- .warn("Couldn't resolve jalview sequenceI for dataset object reference "
- + ((Vobject) dataset.getDataSetAnnotations(
- dsa).getSeqRef(0)).getVorbaId()
- .getId());
+ jalview.bin.Cache.log.warn(
+ "Couldn't resolve jalview sequenceI for dataset object reference "
+ + ((Vobject) dataset
+ .getDataSetAnnotations(dsa)
+ .getSeqRef(0)).getVorbaId()
+ .getId());
}
else
{
// JBPNote: we could just add them to all alignments but
// that may complicate cross references in the jalview
// datamodel
- Cache.log
- .warn("Ignoring dataset annotation with annotationElements. Not yet supported in jalview.");
+ Cache.log.warn(
+ "Ignoring dataset annotation with annotationElements. Not yet supported in jalview.");
}
}
}
else
{
- Cache.log
- .warn("Ignoring multiply referenced dataset sequence annotation for binding to datsaet sequence features.");
+ Cache.log.warn(
+ "Ignoring multiply referenced dataset sequence annotation for binding to datsaet sequence features.");
}
}
}
{
// LOAD ALIGNMENTS from DATASET
- for (int al = 0, nal = dataset.getAlignmentCount(); al < nal; al++)
+ for (int al = 0, nal = dataset
+ .getAlignmentCount(); al < nal; al++)
{
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;
if (av != null)
// TODO check that correct alignment object is retrieved when
// hidden seqs exist.
jal = (av.hasHiddenRows()) ? av.getAlignment()
- .getHiddenSequences().getFullAlignment() : av
- .getAlignment();
+ .getHiddenSequences().getFullAlignment()
+ : av.getAlignment();
}
iSize = alignment.getAlignmentSequenceCount();
boolean refreshal = false;
for (i = 0; i < iSize; i++)
{
AlignmentSequence valseq = alignment.getAlignmentSequence(i);
- jalview.datamodel.Sequence alseq = (jalview.datamodel.Sequence) getvObj2jv(valseq);
+ jalview.datamodel.Sequence alseq = (jalview.datamodel.Sequence) getvObj2jv(
+ valseq);
if (syncFromAlignmentSequence(valseq, valGapchar, gapChar,
dsseqs) && alseq != null)
{
.getAlignmentSequenceAnnotation();
for (int a = 0; a < vasannot.length; a++)
{
- jalview.datamodel.AlignmentAnnotation asa = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(vasannot[a]); // TODO:
+ jalview.datamodel.AlignmentAnnotation asa = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(
+ vasannot[a]); // TODO:
// 1:many
// jalview
// alignment
// OBJECT LOCK
// METHODS)
{
- Cache.log
- .info("UNIMPLEMENTED: not recovering user modifiable sequence alignment annotation");
+ Cache.log.info(
+ "UNIMPLEMENTED: not recovering user modifiable sequence alignment annotation");
// TODO: should at least replace with new one - otherwise
// things will break
// basically do this:
if (newasAnnots != null && newasAnnots.size() > 0)
{
// Add the new sequence annotations in to the alignment.
- for (int an = 0, anSize = newasAnnots.size(); an < anSize; an++)
+ for (int an = 0, anSize = newasAnnots
+ .size(); an < anSize; an++)
{
- jal.addAnnotation((AlignmentAnnotation) newasAnnots
- .elementAt(an));
+ jal.addAnnotation(
+ (AlignmentAnnotation) newasAnnots.elementAt(an));
// TODO: check if anything has to be done - like calling
// adjustForAlignment or something.
newasAnnots.setElementAt(null, an);
for (int j = 0; j < an.length; j++)
{
- jalview.datamodel.AlignmentAnnotation jan = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(an[j]);
+ jalview.datamodel.AlignmentAnnotation jan = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(
+ an[j]);
if (jan != null)
{
// update or stay the same.
// jan.update(getjAlignmentAnnotation(jal, an[a])); // update
// from another annotation object in place.
- Cache.log
- .debug("update from vamsas alignment annotation to existing jalview alignment annotation.");
+ Cache.log.debug(
+ "update from vamsas alignment annotation to existing jalview alignment annotation.");
if (an[j].getModifiable() == null) // TODO: USE VAMSAS
// LIBRARY OBJECT LOCK
// METHODS)
{
// TODO: user defined annotation is totally mutable... - so
// load it up or throw away if locally edited.
- Cache.log
- .info("NOT IMPLEMENTED - Recovering user-modifiable annotation - yet...");
+ Cache.log.info(
+ "NOT IMPLEMENTED - Recovering user-modifiable annotation - yet...");
}
// TODO: compare annotation element rows
// TODO: compare props.
// ///////////////////////////////
// construct alignment view
alignFrame = new AlignFrame(jal, AlignFrame.DEFAULT_WIDTH,
- AlignFrame.DEFAULT_HEIGHT, alignment.getVorbaId()
- .toString());
+ AlignFrame.DEFAULT_HEIGHT,
+ alignment.getVorbaId().toString());
av = alignFrame.getViewport();
newAlignmentViews.addElement(av);
- String title = alignment
- .getProvenance()
+ String title = alignment.getProvenance()
.getEntry(
alignment.getProvenance().getEntryCount() - 1)
.getAction();
if (alignment.getPropertyCount() > 0)
{
- for (int p = 0, pe = alignment.getPropertyCount(); p < pe; p++)
+ for (int p = 0, pe = alignment
+ .getPropertyCount(); p < pe; p++)
{
if (alignment.getProperty(p).getName().equals("title"))
{
TreePanel tp = null;
if (vstree.isValidTree())
{
- tp = alignFrame.ShowNewickTree(vstree.getNewickTree(),
+ tp = alignFrame.showNewickTree(vstree.getNewickTree(),
vstree.getTitle(), vstree.getInputData(), 600,
500, t * 20 + 50, t * 20 + 50);
DataSet dataset = root.getDataSet(_ds);
if (dataset.getSequenceMappingCount() > 0)
{
- for (int sm = 0, smCount = dataset.getSequenceMappingCount(); sm < smCount; sm++)
+ for (int sm = 0, smCount = dataset
+ .getSequenceMappingCount(); sm < smCount; sm++)
{
Rangetype seqmap = new jalview.io.vamsas.Sequencemapping(this,
dataset.getSequenceMapping(sm));
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)
{
}
// bitfields - should be a template in j1.5
- private static int HASSECSTR = 0;
+ private static final int HASSECSTR = 0;
- private static int HASVALS = 1;
+ private static final int HASVALS = 1;
- private static int HASHPHOB = 2;
+ private static final int HASHPHOB = 2;
- private static int HASDC = 3;
+ private static final int HASDC = 3;
- private static int HASDESCSTR = 4;
+ private static final int HASDESCSTR = 4;
- private static int HASTWOSTATE = 5; // not used yet.
+ private static final int HASTWOSTATE = 5; // not used yet.
/**
* parses the AnnotationElements - if they exist - into
// may not quite cope with this (without binding an array of annotations to
// a vamsas alignment annotation)
// summary flags saying what we found over the set of annotation rows.
- boolean[] AeContent = new boolean[]
- { false, false, false, false, false };
+ boolean[] AeContent = new boolean[] { false, false, false, false,
+ false };
int[] rangeMap = getMapping(annotation);
- jalview.datamodel.Annotation[][] anot = new jalview.datamodel.Annotation[][]
- { new jalview.datamodel.Annotation[rangeMap.length],
+ jalview.datamodel.Annotation[][] anot = new jalview.datamodel.Annotation[][] {
+ new jalview.datamodel.Annotation[rangeMap.length],
new jalview.datamodel.Annotation[rangeMap.length] };
boolean mergeable = true; // false if 'after positions cant be placed on
// same annotation row as positions.
Glyph[] glyphs = ae[aa].getGlyph();
for (int g = 0; g < glyphs.length; g++)
{
- if (glyphs[g]
- .getDict()
- .equals(uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_SS_3STATE))
+ if (glyphs[g].getDict().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))
+ else if (glyphs[g].getDict().equals(
+ uk.ac.vamsas.objects.utils.GlyphDictionary.PROTEIN_HD_HYDRO))
{
Cache.log.debug("ignoring hydrophobicity glyph marker.");
AeContent[HASHPHOB] = true;
}
else
{
- Cache.log
- .debug("IMPLEMENTATION TODO: Ignoring unknown glyph type "
+ Cache.log.debug(
+ "IMPLEMENTATION TODO: Ignoring unknown glyph type "
+ glyphs[g].getDict());
}
}
AeContent[HASVALS] = true;
if (ae[aa].getValueCount() > 1)
{
- Cache.log.warn("ignoring additional "
- + (ae[aa].getValueCount() - 1)
- + " values in annotation element.");
+ Cache.log.warn(
+ "ignoring additional " + (ae[aa].getValueCount() - 1)
+ + " values in annotation element.");
}
val = ae[aa].getValue(0);
}
anot[1][i].description = anot[1][i].description + " (after)";
}
}
- return new Object[]
- { AeContent, rangeMap, anot[0], anot[1] };
+ return new Object[] { AeContent, rangeMap, anot[0], anot[1] };
}
else
{
// no annotations to parse. Just return an empty annotationElement[]
// array.
- return new Object[]
- { AeContent, rangeMap, anot[0], anot[1] };
+ return new Object[] { AeContent, rangeMap, anot[0], anot[1] };
}
// return null;
}
Cache.log.warn("Failed to parse threshold property");
}
if (val != null)
+ {
if (gl == null)
{
- gl = new GraphLine(val.floatValue(), "", java.awt.Color.black);
+ gl = new GraphLine(val.floatValue(), "",
+ java.awt.Color.black);
}
else
{
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();
}
}
}
if (parsedRangeAnnotation == null)
{
- Cache.log
- .debug("Inserting empty annotation row elements for a whole-alignment annotation.");
+ Cache.log.debug(
+ "Inserting empty annotation row elements for a whole-alignment annotation.");
}
else
{
&& arow[i].description.length() < 3)
{
// copy over the description as the display char.
- arow[i].displayCharacter = new String(arow[i].description);
+ arow[i].displayCharacter = new String(
+ arow[i].description);
}
}
else
}
} catch (Exception e)
{
- Cache.log
- .info("UNIMPLEMENTED : Couldn't parse non-integer group value for setting graphGroup correctly.");
+ Cache.log.info(
+ "UNIMPLEMENTED : Couldn't parse non-integer group value for setting graphGroup correctly.");
}
return jan;
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)
{
// could do a polarity for pos range too. and pass back indication of
// discontinuities.
int pos = dseta.getPos(0).getI();
- se = new int[]
- { pos, pos };
+ se = new int[] { pos, pos };
for (int p = 0, pSize = dseta.getPosCount(); p < pSize; p++)
{
pos = dseta.getPos(p).getI();
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)
{
* @param maprange
* where the from range is the local mapped range, and the to range
* is the 'mapped' range in the MapRangeType
- * @param default unit for local
- * @param default unit for mapped
+ * @param default
+ * unit for local
+ * @param default
+ * unit for mapped
* @return MapList
*/
private jalview.util.MapList parsemapType(MapType maprange, int localu,
int[] mappedRange = getMapping(maprange.getMapped());
long lu = maprange.getLocal().hasUnit() ? maprange.getLocal().getUnit()
: localu;
- long mu = maprange.getMapped().hasUnit() ? maprange.getMapped()
- .getUnit() : mappedu;
+ long mu = maprange.getMapped().hasUnit()
+ ? maprange.getMapped().getUnit()
+ : mappedu;
ml = new jalview.util.MapList(localRange, mappedRange, (int) lu,
(int) mu);
return ml;
* 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<int[]> 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);
}
}
jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance();
for (int i = 0; i < prov.getEntryCount(); i++)
{
- jprov.addEntry(prov.getEntry(i).getUser(), prov.getEntry(i)
- .getAction(), prov.getEntry(i).getDate(), prov.getEntry(i)
- .getId());
+ jprov.addEntry(prov.getEntry(i).getUser(),
+ prov.getEntry(i).getAction(), prov.getEntry(i).getDate(),
+ prov.getEntry(i).getId());
}
return jprov;
return vobj2jv;
}
- public void storeSequenceMappings(AlignViewport viewport, String title)
- throws Exception
+ public void storeSequenceMappings(AlignmentViewport viewport,
+ String title) throws Exception
{
- AlignViewport av = viewport;
+ AlignmentViewport av = viewport;
try
{
jalview.datamodel.AlignmentI jal = av.getAlignment();
Cache.log.warn("Creating new dataset for an alignment.");
jal.setDataset(null);
}
- dataset = (DataSet) ((Alignment) getjv2vObj(viewport
- .getSequenceSetId())).getV_parent(); // jal.getDataset());
+ dataset = (DataSet) ((Alignment) getjv2vObj(
+ viewport.getSequenceSetId())).getV_parent(); // jal.getDataset());
if (dataset == null)
{
dataset = (DataSet) getjv2vObj(jal.getDataset());
- Cache.log
- .error("Can't find the correct dataset for the alignment in this view. Creating new one.");
+ Cache.log.error(
+ "Can't find the correct dataset for the alignment in this view. Creating new one.");
}
// Store any sequence mappings.
- if (av.getAlignment().getCodonFrames() != null
- && av.getAlignment().getCodonFrames().length > 0)
+ List<AlignedCodonFrame> 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]);
+ uk.ac.vamsas.objects.core.SequenceType mfrom = (SequenceType) getjv2vObj(
+ dmps[smp]);
if (mfrom != null)
{
- new jalview.io.vamsas.Sequencemapping(this, mps[smp],
- mfrom, dataset);
+ new jalview.io.vamsas.Sequencemapping(this, mps[smp], mfrom,
+ dataset);
}
else
{
- Cache.log
- .warn("NO Vamsas Binding for local sequence! NOT CREATING MAPPING FOR "
- + dmps[smp].getDisplayId(true)
- + " to "
+ Cache.log.warn(
+ "NO Vamsas Binding for local sequence! NOT CREATING MAPPING FOR "
+ + dmps[smp].getDisplayId(true) + " to "
+ mps[smp].getTo().getName());
}
}
}
} 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);
}
}