*/
package jalview.datamodel;
+import jalview.util.MessageManager;
+
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
*/
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);
}
public SequenceI[] getSequencesArray()
{
if (sequences == null)
+ {
return null;
+ }
synchronized (sequences)
{
return sequences.toArray(new SequenceI[sequences.size()]);
}
}
if (hiddenSequences != null)
+ {
hiddenSequences.adjustHeightSequenceAdded();
+ }
}
/**
public void finalize()
{
if (getDataset() != null)
+ {
getDataset().removeAlignmentRef();
+ }
dataset = null;
sequences = null;
continue;
}
if (tIndex < temp.length)
+ {
temp[tIndex++] = annotations[i];
+ }
}
if (swap)
else if (dataset == null && data != null)
{
dataset = data;
+ for (int i = 0; i < getHeight(); i++)
+ {
+ SequenceI currentSeq = getSequenceAt(i);
+ SequenceI dsq = currentSeq.getDatasetSequence();
+ if (dsq == null)
+ {
+ dsq = currentSeq.createDatasetSequence();
+ dataset.addSequence(dsq);
+ }
+ else
+ {
+ while (dsq.getDatasetSequence() != null)
+ {
+ dsq = dsq.getDatasetSequence();
+ }
+ if (dataset.findIndex(dsq) == -1)
+ {
+ dataset.addSequence(dsq);
+ }
+ }
+ }
}
dataset.addAlignmentRef();
}
public void setProperty(Object key, Object value)
{
if (alignmentProperties == null)
+ {
alignmentProperties = new Hashtable();
+ }
alignmentProperties.put(key, value);
}
public Object getProperty(Object key)
{
if (alignmentProperties != null)
+ {
return alignmentProperties.get(key);
+ }
else
+ {
return null;
+ }
}
@Override
public void addCodonFrame(AlignedCodonFrame codons)
{
if (codons == null)
+ {
return;
+ }
if (codonFrameList == null)
{
codonFrameList = new AlignedCodonFrame[]
public AlignedCodonFrame[] getCodonFrame(SequenceI seq)
{
if (seq == null || codonFrameList == null)
+ {
return null;
+ }
Vector cframes = new Vector();
for (int f = 0; f < codonFrameList.length; f++)
{
if (codonFrameList[f].involvesSequence(seq))
+ {
cframes.addElement(codonFrameList[f]);
+ }
}
if (cframes.size() == 0)
+ {
return null;
+ }
AlignedCodonFrame[] cfr = new AlignedCodonFrame[cframes.size()];
cframes.copyInto(cfr);
return cfr;
public boolean removeCodonFrame(AlignedCodonFrame codons)
{
if (codons == null || codonFrameList == null)
+ {
return false;
+ }
boolean removed = false;
int i = 0, iSize = codonFrameList.length;
while (i < iSize)
{
return dataset;
}
-
- /**
- * Returns an iterable collection of annotations on this alignment which match
- * the given criteria.
- */
- @Override
- public Iterable<AlignmentAnnotation> findAnnotation(SequenceI datasequence,
- String calcId, String label)
- {
- List<AlignmentAnnotation> result = new ArrayList<AlignmentAnnotation>();
- for (AlignmentAnnotation ann : annotations)
- {
- // only sequence-linked annotations can qualify (have a datasequence)
- if (ann.sequenceRef == null)
- {
- continue;
- }
- boolean matchDatasequence = (ann.sequenceRef.getDatasetSequence() == datasequence);
- final String annCalcId = ann.getCalcId();
- boolean matchCalcId = (annCalcId != null && annCalcId.equals(calcId));
- boolean matchLabel = (ann.label != null && ann.label.equals(label));
- if (matchDatasequence && matchCalcId && matchLabel)
- {
- result.add(ann);
- }
- }
- return result;
- }
}