import jalview.util.MapList;
-import java.util.Enumeration;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
* Stores mapping between the columns of a protein alignment and a DNA alignment
* and a list of individual codon to amino acid mappings between sequences.
*/
-
public class AlignedCodonFrame
{
+
/**
* array of nucleotide positions for aligned codons at column of aligned
* proteins.
*/
public int aaWidth = 0;
+ /*
+ * TODO: not an ideal solution - we reference the aligned amino acid sequences
+ * in order to make insertions on them Better would be dnaAlignment and
+ * aaAlignment reference....
+ */
+ private List<SequenceI> a_aaSeqs = new ArrayList<SequenceI>();
+
+ /*
+ * tied array of na Sequence objects.
+ */
+ private SequenceI[] dnaSeqs = null;
+
+ /*
+ * tied array of Mappings to protein sequence Objects and SequenceI[]
+ * aaSeqs=null; MapLists where eac maps from the corresponding dnaSeqs element
+ * to corresponding aaSeqs element
+ */
+ private Mapping[] dnaToProt = null;
+
/**
* initialise codon frame with a nominal alignment width
*
}
/**
+ * Construct a 'near copy' of the given AlignedCodonFrame, that references the
+ * same dataset sequences, but the given protein aligned sequences.
+ *
+ * @param acf
+ * @param alignment
+ * @throws IllegalStateException
+ * if the copied mapping references any dataset not in the alignment
+ */
+ public AlignedCodonFrame(AlignedCodonFrame acf, SequenceI[] alignment)
+ {
+ this.codons = acf.codons;
+ this.dnaSeqs = acf.dnaSeqs;
+ this.dnaToProt = acf.dnaToProt;
+
+ for (SequenceI seq : acf.a_aaSeqs)
+ {
+ boolean found = false;
+ for (SequenceI newseq : alignment)
+ {
+ if (seq.getDatasetSequence() == newseq.getDatasetSequence())
+ {
+ this.a_aaSeqs.add(newseq);
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ throw new IllegalStateException("Copying codon mapping for"
+ + seq.getSequenceAsString());
+ }
+ }
+ }
+
+ /**
* ensure that codons array is at least as wide as aslen residues
*
* @param aslen
}
/**
- * TODO: not an ideal solution - we reference the aligned amino acid sequences
- * in order to make insertions on them Better would be dnaAlignment and
- * aaAlignment reference....
- */
- Vector a_aaSeqs = new Vector();
-
- /**
* increase aaWidth by one and insert a new aligned codon position space at
* aspos.
*
// this aa appears before the aligned codons at aspos - so shift them in
// each pair of mapped sequences
aaWidth++;
- if (a_aaSeqs != null)
+ // we actually have to modify the aligned sequences here, so use the
+ // a_aaSeqs vector
+ for (SequenceI seq : a_aaSeqs)
{
- // we actually have to modify the aligned sequences here, so use the
- // a_aaSeqs vector
- Enumeration sq = a_aaSeqs.elements();
- while (sq.hasMoreElements())
- {
- ((SequenceI) sq.nextElement()).insertCharAt(aspos, gapCharacter);
- }
+ seq.insertCharAt(aspos, gapCharacter);
}
+
checkCodonFrameWidth(aspos);
if (aspos < aaWidth)
{
}
/**
- * tied array of na Sequence objects.
- */
- SequenceI[] dnaSeqs = null;
-
- /**
- * tied array of Mappings to protein sequence Objects and SequenceI[]
- * aaSeqs=null; MapLists where eac maps from the corresponding dnaSeqs element
- * to corresponding aaSeqs element
- */
- Mapping[] dnaToProt = null;
-
- /**
* add a mapping between the dataset sequences for the associated dna and
* protein sequence objects
*
// aaseq.transferAnnotation(dnaseq, new Mapping(map.getInverse()));
mp.to = (aaseq.getDatasetSequence() == null) ? aaseq : aaseq
.getDatasetSequence();
- a_aaSeqs.addElement(aaseq);
+ a_aaSeqs.add(aaseq);
dnaToProt[nlen] = mp;
}
{
// TODO very fragile - depends on dnaSeqs, dnaToProt, a_aaSeqs moving
// in parallel; revise data model to guarantee this
- return (SequenceI) a_aaSeqs.elementAt(ds);
+ return a_aaSeqs.get(ds);
}
}
}
import jalview.datamodel.AlignmentView;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
-import jalview.gui.WebserviceInfo;
import jalview.gui.FeatureRenderer.FeatureRendererSettings;
+import jalview.gui.WebserviceInfo;
import jalview.util.MessageManager;
public abstract class AWSThread extends Thread
{
for (int i = 0; i < codonframe.length; i++)
{
- if (codonframe[i] != null
- && codonframe[i].involvesSequence(alignment[sq]))
+ AlignedCodonFrame acf = codonframe[i];
+ final SequenceI seq = alignment[sq];
+ if (acf != null && acf.involvesSequence(seq))
{
- al.addCodonFrame(codonframe[i]);
+ al.addCodonFrame(new AlignedCodonFrame(acf, alignment));
codonframe[i] = null;
break;
}