/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, 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.
- *
- * 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
+ * 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 <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.datamodel;
+import jalview.util.MessageManager;
+
import java.util.*;
/**
*/
/**
* @author JimP
- *
+ *
*/
public class Alignment implements AlignmentI
{
/**
* Make an alignment from an array of Sequences.
- *
+ *
* @param sequences
*/
public Alignment(SequenceI[] seqs)
/**
* Make a new alignment from an array of SeqCigars
- *
+ *
* @param seqs
* SeqCigar[]
*/
* compactAlignment does not contain hidden regions. JBPNote - must also check
* that compactAlignment resolves to a set of SeqCigars - or construct them
* appropriately.
- *
+ *
* @param compactAlignment
* CigarArray
*/
public static AlignmentI createAlignment(CigarArray compactAlignment)
{
- throw new Error("Alignment(CigarArray) not yet implemented");
+ throw new Error(MessageManager.getString("error.alignment_cigararray_not_implemented"));
// this(compactAlignment.refCigars);
}
/**
* DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
*/
@Override
/**
* DOCUMENT ME!
- *
+ *
* @param i
* DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
*/
@Override
/**
* Adds a sequence to the alignment. Recalculates maxLength and size.
- *
+ *
* @param snew
*/
@Override
/**
* Adds a sequence to the alignment. Recalculates maxLength and size.
- *
+ *
* @param snew
*/
@Override
/**
* DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
*/
@Override
/**
* DOCUMENT ME!
- *
+ *
* @param s
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @param i
* DOCUMENT ME!
*/
/*
* (non-Javadoc)
- *
+ *
* @see jalview.datamodel.AlignmentI#findGroup(jalview.datamodel.SequenceI)
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.datamodel.AlignmentI#findAllGroups(jalview.datamodel.SequenceI)
*/
return;
}
}
-
+ sg.setContext(this);
groups.add(sg);
}
}
/**
* remove any annotation that references gp
- *
+ *
* @param gp
* (if null, removes all group associated annotation)
*/
{
removeAnnotationForGroup(null);
}
+ for (SequenceGroup sg : groups)
+ {
+ sg.setContext(null);
+ }
groups.clear();
}
}
{
removeAnnotationForGroup(g);
groups.remove(g);
+ g.setContext(null);
}
}
}
/*
* (non-Javadoc)
- *
+ *
* @see jalview.datamodel.AlignmentI#findName(java.lang.String, boolean)
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see jalview.datamodel.AlignmentI#findName(SequenceI, java.lang.String,
* boolean)
*/
/*
* (non-Javadoc)
- *
+ *
* @see jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SequenceI)
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SearchResults)
*/
/**
* DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
*/
@Override
/**
* DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
*/
@Override
/**
* DOCUMENT ME!
- *
+ *
* @param gc
* DOCUMENT ME!
*/
/**
* DOCUMENT ME!
- *
+ *
* @return DOCUMENT ME!
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see jalview.datamodel.AlignmentI#isAligned()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see jalview.datamodel.AlignmentI#isAligned(boolean)
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @seejalview.datamodel.AlignmentI#deleteAnnotation(jalview.datamodel.
* AlignmentAnnotation)
*/
/**
* remove any object references associated with this annotation
- *
+ *
* @param aa
*/
private void unhookAnnotation(AlignmentAnnotation aa)
/*
* (non-Javadoc)
- *
+ *
* @seejalview.datamodel.AlignmentI#addAnnotation(jalview.datamodel.
* AlignmentAnnotation)
*/
/*
* (non-Javadoc)
- *
+ *
* @seejalview.datamodel.AlignmentI#addAnnotation(jalview.datamodel.
* AlignmentAnnotation, int)
*/
/**
* Justify the sequences to the left or right by deleting and inserting gaps
* before the initial residue or after the terminal residue
- *
+ *
* @param right
* true if alignment padded to right, false to justify to left
* @return true if alignment was changed
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.datamodel.AlignmentI#addCodonFrame(jalview.datamodel.AlignedCodonFrame
* )
/*
* (non-Javadoc)
- *
+ *
* @see jalview.datamodel.AlignmentI#getCodonFrame(int)
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see
* jalview.datamodel.AlignmentI#getCodonFrame(jalview.datamodel.SequenceI)
*/
/*
* (non-Javadoc)
- *
+ *
* @see jalview.datamodel.AlignmentI#getCodonFrames()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @seejalview.datamodel.AlignmentI#removeCodonFrame(jalview.datamodel.
* AlignedCodonFrame)
*/
@Override
public AlignmentAnnotation findOrCreateAnnotation(String name,
- boolean autoCalc, SequenceI seqRef, SequenceGroup groupRef)
+ String calcId, boolean autoCalc, SequenceI seqRef,
+ SequenceGroup groupRef)
{
- for (AlignmentAnnotation annot : getAlignmentAnnotation())
+ assert (name != null);
+ if (annotations != null)
{
- if (annot.autoCalculated == autoCalc
- && annot.getCalcId().equals(name)
- && annot.sequenceRef == seqRef && annot.groupRef == groupRef)
+ for (AlignmentAnnotation annot : getAlignmentAnnotation())
{
- return annot;
+ if (annot.autoCalculated == autoCalc && (name.equals(annot.label))
+ && (calcId == null || annot.getCalcId().equals(calcId))
+ && annot.sequenceRef == seqRef
+ && annot.groupRef == groupRef)
+ {
+ return annot;
+ }
}
}
AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
annot.hasText = false;
- annot.setCalcId(new String(name));
+ annot.setCalcId(new String(calcId));
annot.autoCalculated = autoCalc;
if (seqRef != null)
{
}
}
+ @Override
+ public void validateAnnotation(AlignmentAnnotation alignmentAnnotation)
+ {
+ alignmentAnnotation.validateRangeAndDisplay();
+ if (isNucleotide() && alignmentAnnotation.isValidStruc())
+ {
+ hasRNAStructure = true;
+ }
+ }
+
+ @Override
+ public int getEndRes()
+ {
+ return getWidth() - 1;
+ }
+
+ @Override
+ public int getStartRes()
+ {
+ return 0;
+ }
+
+ /*
+ * In the case of AlignmentI - returns the dataset for the alignment, if set
+ * (non-Javadoc)
+ *
+ * @see jalview.datamodel.AnnotatedCollectionI#getContext()
+ */
+ @Override
+ public AnnotatedCollectionI getContext()
+ {
+ return dataset;
+ }
}