/**
* Constructs an alignment consisting of the mapped exon regions in the given
- * nucleotide sequences, and updates mappings to match.
+ * nucleotide sequences, and updates mappings to match. The new alignment's
+ * sequences are added to the parent alignment's dataset, and both alignments
+ * share the same dataset.
*
* @param dna
* aligned dna sequences
* sequences (or null if no exons are found)
*/
public static AlignmentI makeExonAlignment(SequenceI[] dna,
- Set<AlignedCodonFrame> mappings)
+ Set<AlignedCodonFrame> mappings, AlignmentI al)
{
Set<AlignedCodonFrame> newMappings = new LinkedHashSet<AlignedCodonFrame>();
List<SequenceI> exonSequences = new ArrayList<SequenceI>();
}
}
}
- AlignmentI al = new Alignment(
+ AlignmentI cds = new Alignment(
exonSequences.toArray(new SequenceI[exonSequences.size()]));
- 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 : cds.getSequences())
+ {
+ if (!dsseqs.contains(seq.getDatasetSequence()))
+ {
+ dsseqs.add(seq.getDatasetSequence());
+ }
+ }
+ cds.setDataset(al.getDataset());
/*
* Replace the old mappings with the new ones
mappings.clear();
mappings.addAll(newMappings);
- return al;
+ return cds;
}
/**