* aligned dna sequences
* @param mappings
* from dna to protein; these are replaced with new mappings
- * @param gapChar
+ * @param al
* @return an alignment whose sequences are the cds-only parts of the dna
* sequences (or null if no mappings are found)
*/
public static AlignmentI makeCdsAlignment(SequenceI[] dna,
- List<AlignedCodonFrame> mappings, char gapChar)
+ List<AlignedCodonFrame> mappings, AlignmentI al)
{
List<int[]> cdsColumns = findCdsColumns(dna);
*/
List<AlignedCodonFrame> newMappings = new ArrayList<AlignedCodonFrame>();
List<SequenceI> cdsSequences = new ArrayList<SequenceI>();
+ char gap = al.getGapCharacter();
for (SequenceI dnaSeq : dna)
{
{
AlignedCodonFrame newMapping = new AlignedCodonFrame();
final List<SequenceI> mappedCds = makeCdsSequences(dnaSeq, acf,
- cdsColumns, newMapping, gapChar);
+ cdsColumns, newMapping, gap);
if (!mappedCds.isEmpty())
{
cdsSequences.addAll(mappedCds);
}
}
}
- AlignmentI al = new Alignment(
+ AlignmentI newAl = new Alignment(
cdsSequences.toArray(new SequenceI[cdsSequences.size()]));
- al.setGapCharacter(gapChar);
- al.setDataset(null);
+
+ /*
+ * add new sequences to the shared dataset, set it on the new alignment
+ */
+ List<SequenceI> dsseqs = al.getDataset().getSequences();
+ for (SequenceI seq : newAl.getSequences())
+ {
+ if (!dsseqs.contains(seq.getDatasetSequence()))
+ {
+ dsseqs.add(seq.getDatasetSequence());
+ }
+ }
+ newAl.setDataset(al.getDataset());
/*
* Replace the old mappings with the new ones
mappings.clear();
mappings.addAll(newMappings);
- return al;
+ return newAl;
}
/**
{
SequenceI cds = makeCdsSequence(dnaSeq, seqMapping,
ungappedCdsColumns, gapChar);
+ cds.createDatasetSequence();
cdsSequences.add(cds);
/*