X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fpacked%2FJalviewDataset.java;h=c79c63ab549e471f8a53db20efcef73bf074c475;hb=d9c7868a610eff29a8eddb160b6dc78a94a72470;hp=1972189fc31354c717790bc2a5518e3455186a8c;hpb=332327b9f2272674f8da954d76805ff3754b8ab3;p=jalview.git
diff --git a/src/jalview/io/packed/JalviewDataset.java b/src/jalview/io/packed/JalviewDataset.java
index 1972189..c79c63a 100644
--- a/src/jalview/io/packed/JalviewDataset.java
+++ b/src/jalview/io/packed/JalviewDataset.java
@@ -1,12 +1,35 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
+ * Copyright (C) 2015 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.
+ *
+ * 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 .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.io.packed;
+import jalview.api.FeatureColourI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.io.NewickFile;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
public class JalviewDataset
{
@@ -22,27 +45,33 @@ public class JalviewDataset
{
return parentDataset;
}
+
/**
- * @param parentDataset the parentDataset to set
+ * @param parentDataset
+ * the parentDataset to set
*/
public void setParentDataset(AlignmentI parentDataset)
{
this.parentDataset = parentDataset;
}
+
/**
* @return the featureColours
*/
- public Hashtable getFeatureColours()
+ public Map getFeatureColours()
{
return featureColours;
}
+
/**
- * @param featureColours the featureColours to set
+ * @param featureColours
+ * the featureColours to set
*/
- public void setFeatureColours(Hashtable featureColours)
+ public void setFeatureColours(Map featureColours)
{
this.featureColours = featureColours;
}
+
/**
* @return the seqDetails
*/
@@ -50,88 +79,106 @@ public class JalviewDataset
{
return seqDetails;
}
+
/**
- * @param seqDetails the seqDetails to set
+ * @param seqDetails
+ * the seqDetails to set
*/
public void setSeqDetails(Hashtable seqDetails)
{
this.seqDetails = seqDetails;
}
+
/**
* @return the al
*/
public List getAl()
{
- return (al==null) ? new ArrayList() : al;
+ return (al == null) ? new ArrayList() : al;
}
+
/**
* current alignment being worked on.
*/
List al;
- public class AlignmentSet {
- AlignmentI al;
- List trees;
- AlignmentSet(AlignmentI a) {
+
+ public class AlignmentSet
+ {
+ public AlignmentI al;
+
+ public List trees;
+
+ AlignmentSet(AlignmentI a)
+ {
al = a;
trees = new ArrayList();
}
+
/**
* deuniquify the current alignment in the context, merging any new
* annotation/features with the existing set
*
* @param context
*/
- void deuniquifyAlignment()
+ void deuniquifyAlignment()
+ {
+ if (seqDetails == null || seqDetails.size() == 0)
{
- if (seqDetails==null || seqDetails.size()==0)
- {
- // nothing to do
- return;
- }
- // 1. recover correct names and attributes for each sequence in alignment.
- /*
- * TODO: housekeeping w.r.t. recovery of dataset and annotation
- * references for input sequences, and then dataset sequence creation
- * for new sequences retrieved from service // finally, attempt to
- * de-uniquify to recover input sequence identity, and try to map back
- * onto dataset Note: this
- * jalview.analysis.SeqsetUtils.deuniquify(SeqNames, alseqs, true); will
- * NOT WORK - the returned alignment may contain multiple versions of
- * the input sequence, each being a subsequence of the original.
- * deuniquify also removes existing annotation and features added in the
- * previous step... al.setDataset(dataset); // add in new sequences
- * retrieved from sequence search which are not already in dataset. //
- * trigger a 'fetchDBids' to annotate sequences with database ids...
- */
- //jalview.analysis.SeqsetUtils.deuniquifyAndMerge(parentDataset, seqDetails, al,true);
-
- jalview.analysis.SeqsetUtils.deuniquify(seqDetails, al.getSequencesArray(),true);
- // 2. Update names of associated nodes in any trees
- for (NewickFile nf:trees)
- {
- // the following works because all trees are already had node/SequenceI associations created.
- jalview.analysis.NJTree njt = new jalview.analysis.NJTree(al.getSequencesArray(), nf);
- // this just updates the displayed leaf name on the tree according to the SequenceIs.
- njt.renameAssociatedNodes();
- }
-
+ // nothing to do
+ return;
}
- /**
- * set modification flag. If anything modifies the alignment in the current set, this flag should be true
+ // 1. recover correct names and attributes for each sequence in alignment.
+ /*
+ * TODO: housekeeping w.r.t. recovery of dataset and annotation references
+ * for input sequences, and then dataset sequence creation for new
+ * sequences retrieved from service // finally, attempt to de-uniquify to
+ * recover input sequence identity, and try to map back onto dataset Note:
+ * this jalview.analysis.SeqsetUtils.deuniquify(SeqNames, alseqs, true);
+ * will NOT WORK - the returned alignment may contain multiple versions of
+ * the input sequence, each being a subsequence of the original.
+ * deuniquify also removes existing annotation and features added in the
+ * previous step... al.setDataset(dataset); // add in new sequences
+ * retrieved from sequence search which are not already in dataset. //
+ * trigger a 'fetchDBids' to annotate sequences with database ids...
*/
- private boolean modified=false;
-
- /**
- * @return the modified
- */
- public boolean isModified()
+ // jalview.analysis.SeqsetUtils.deuniquifyAndMerge(parentDataset,
+ // seqDetails, al,true);
+
+ jalview.analysis.SeqsetUtils.deuniquify(seqDetails,
+ al.getSequencesArray(), true);
+ // 2. Update names of associated nodes in any trees
+ for (NewickFile nf : trees)
{
- return modified;
+ // the following works because all trees are already had node/SequenceI
+ // associations created.
+ jalview.analysis.NJTree njt = new jalview.analysis.NJTree(
+ al.getSequencesArray(), nf);
+ // this just updates the displayed leaf name on the tree according to
+ // the SequenceIs.
+ njt.renameAssociatedNodes();
}
- /**
- * or the modification state with the given state
- * @param modifiedFromAction
- */
+
+ }
+
+ /**
+ * set modification flag. If anything modifies the alignment in the current
+ * set, this flag should be true
+ */
+ private boolean modified = false;
+
+ /**
+ * @return the modified
+ */
+ public boolean isModified()
+ {
+ return modified;
+ }
+
+ /**
+ * or the modification state with the given state
+ *
+ * @param modifiedFromAction
+ */
public void updateSetModified(boolean modifiedFromAction)
{
modified |= modifiedFromAction;
@@ -141,113 +188,143 @@ public class JalviewDataset
/**
* current set of feature colours
*/
- Hashtable featureColours;
+ Map featureColours;
/**
* original identity of each sequence in results
*/
Hashtable seqDetails;
+ public boolean relaxedIdMatching = false;
+
public JalviewDataset()
{
seqDetails = new Hashtable();
al = new ArrayList();
parentDataset = null;
- featureColours = new Hashtable();
+ featureColours = new HashMap();
}
+
/**
* context created from an existing alignment.
+ *
* @param parentAlignment
*/
- public JalviewDataset(AlignmentI aldataset, Hashtable fc, Hashtable seqDets)
+ public JalviewDataset(AlignmentI aldataset,
+ Map fc, Hashtable seqDets)
{
+ // TODO not used - remove?
this(aldataset, fc, seqDets, null);
}
+
/**
*
- * @param aldataset - parent dataset for any new alignment/sequence data (must not be null)
- * @param fc (may be null) feature settings for the alignment where new feature renderstyles are stored
- * @param seqDets - (may be null) anonymised sequence information created by Sequence uniquifier
- * @param parentAlignment (may be null) alignment to associate new annotation and trees with.
+ * @param aldataset
+ * - parent dataset for any new alignment/sequence data (must not be
+ * null)
+ * @param fc
+ * (may be null) feature settings for the alignment where new feature
+ * renderstyles are stored
+ * @param seqDets
+ * - (may be null) anonymised sequence information created by
+ * Sequence uniquifier
+ * @param parentAlignment
+ * (may be null) alignment to associate new annotation and trees
+ * with.
*/
- public JalviewDataset(AlignmentI aldataset, Hashtable fc, Hashtable seqDets, AlignmentI parentAlignment)
+ public JalviewDataset(AlignmentI aldataset,
+ Map fc, Hashtable seqDets,
+ AlignmentI parentAlignment)
{
this();
parentDataset = aldataset;
- if (parentAlignment!=null)
+ if (parentAlignment != null)
{
parentDataset = parentAlignment.getDataset();
- if (parentDataset==null)
+ if (parentDataset == null)
{
parentDataset = parentAlignment;
- } else {
+ }
+ else
+ {
addAlignment(parentAlignment);
}
}
- if (seqDets!=null)
+ if (seqDets != null)
{
seqDetails = seqDets;
}
- if (fc!=null)
+ if (fc != null)
{
featureColours = fc;
}
-
-
+
}
public boolean hasAlignments()
{
- return al!=null && al.size()>0;
+ return al != null && al.size() > 0;
}
public AlignmentI getLastAlignment()
{
- return (al==null || al.size()<1) ? null: al.get(al.size()-1).al;
+ return (al == null || al.size() < 1) ? null : al.get(al.size() - 1).al;
}
+
public AlignmentSet getLastAlignmentSet()
{
- return (al==null || al.size()<1) ? null: al.get(al.size()-1);
+ return (al == null || al.size() < 1) ? null : al.get(al.size() - 1);
}
/**
- * post process (deuniquify) the current alignment and its dependent data, and then add newal to the dataset.
+ * post process (deuniquify) the current alignment and its dependent data, and
+ * then add newal to the dataset.
+ *
* @param newal
*/
-public void addAlignment(AlignmentI newal) {
- if (!hasAlignments())
+ public void addAlignment(AlignmentI newal)
{
- al = new ArrayList();
- }
- AlignmentSet last = getLastAlignmentSet();
- if (last!=null) {
- System.err.println("Deuniquifying last alignment set.");
- last.deuniquifyAlignment();
+ if (!hasAlignments())
+ {
+ al = new ArrayList();
+ }
+ AlignmentSet last = getLastAlignmentSet();
+ if (last != null)
+ {
+ System.err.println("Deuniquifying last alignment set.");
+ last.deuniquifyAlignment();
+ }
+ al.add(new AlignmentSet(newal));
}
- al.add(new AlignmentSet(newal));
-}
-public void addTreeFromFile(NewickFile nf)
-{
- AlignmentSet lal = getLastAlignmentSet();
- lal.trees.add(nf);
-}
+ public void addTreeFromFile(NewickFile nf)
+ {
+ AlignmentSet lal = getLastAlignmentSet();
+ lal.trees.add(nf);
+ }
-public boolean hasSequenceAssoc()
-{
- // TODO: discover where sequence associated data should be put.
- return false;
-}
-public SequenceI getLastAssociatedSequence() {
- // TODO: delineate semantics for associating uniquified data with potentially de-uniquified sequence.
- return null;
-}
-/**
- * update the modified state flag for the current set with the given modification state
- * @param modified - this will be ored with current modification state
- */
-public void updateSetModified(boolean modified)
-{
- getLastAlignmentSet().updateSetModified(modified);
+ public boolean hasSequenceAssoc()
+ {
+ // TODO: discover where sequence associated data should be put.
+ return false;
+ }
+
+ public SequenceI getLastAssociatedSequence()
+ {
+ // TODO: delineate semantics for associating uniquified data with
+ // potentially de-uniquified sequence.
+ return null;
+ }
+
+ /**
+ * update the modified state flag for the current set with the given
+ * modification state
+ *
+ * @param modified
+ * - this will be ored with current modification state
+ */
+ public void updateSetModified(boolean modified)
+ {
+ getLastAlignmentSet().updateSetModified(modified);
+ }
}
-}
\ No newline at end of file