* didn't find mapped CDS sequence - construct it and add
* its dataset sequence to the dataset
*/
- cdsSeq = makeCdsSequence(dnaSeq.getDatasetSequence(), aMapping);
+ cdsSeq = makeCdsSequence(dnaSeq.getDatasetSequence(), aMapping,
+ dataset).deriveSequence();
// cdsSeq has a name constructed as CDS|<dbref>
// <dbref> will be either the accession for the coding sequence,
// marked in the /via/ dbref to the protein product accession
// or it will be the original nucleotide accession.
- SequenceI cdsSeqDss = cdsSeq.createDatasetSequence();
+ SequenceI cdsSeqDss = cdsSeq.getDatasetSequence();
+
cdsSeqs.add(cdsSeq);
+
if (!dataset.getSequences().contains(cdsSeqDss))
{
+ // check if this sequence is a newly created one
+ // so needs adding to the dataset
dataset.addSequence(cdsSeqDss);
}
*
* @param seq
* @param mapping
+ * @param dataset
+ * - existing dataset. We check for sequences that look like the CDS
+ * we are about to construct, if one exists already, then we will
+ * just return that one.
* @return CDS sequence (as a dataset sequence)
*/
- static SequenceI makeCdsSequence(SequenceI seq, Mapping mapping)
+ static SequenceI makeCdsSequence(SequenceI seq, Mapping mapping,
+ AlignmentI dataset)
{
char[] seqChars = seq.getSequence();
List<int[]> fromRanges = mapping.getMap().getFromRanges();
String mapFromId = mapping.getMappedFromId();
String seqId = "CDS|" + (mapFromId != null ? mapFromId : seq.getName());
SequenceI newSeq = new Sequence(seqId, newSeqChars, 1, newPos);
+ if (dataset != null)
+ {
+ SequenceI[] matches = dataset.findSequenceMatch(newSeq.getName());
+ if (matches != null)
+ {
+ boolean matched = false;
+ for (SequenceI mtch : matches)
+ {
+ if (mtch.getStart() != newSeq.getStart())
+ {
+ continue;
+ }
+ if (mtch.getEnd() != newSeq.getEnd())
+ {
+ continue;
+ }
+ if (!Arrays.equals(mtch.getSequence(), newSeq.getSequence()))
+ {
+ continue;
+ }
+ if (!matched)
+ {
+ matched = true;
+ newSeq = mtch;
+ }
+ else
+ {
+ System.err
+ .println("JAL-2154 regression: warning - found (and ignnored a duplicate CDS sequence):"
+ + mtch.toString());
+ }
+ }
+ }
+ }
// newSeq.setDescription(mapFromId);
return newSeq;