- // 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)
+ return AlignmentUtils.alignProteinAsDna(this, al);
+ }
+
+ char thisGapChar = this.getGapCharacter();
+ String gap = thisIsNucleotide && thatIsProtein ? String
+ .valueOf(new char[]
+ { thisGapChar, thisGapChar, thisGapChar }) : String
+ .valueOf(thisGapChar);
+
+ // TODO handle intron regions? Needs a 'holistic' alignment of dna,
+ // not just sequence by sequence. But how to 'gap' intron regions?
+
+ /*
+ * Get mappings from 'that' alignment's sequences to this.
+ */
+ for (SequenceI alignTo : getSequences())
+ {
+ count += AlignmentUtils.alignSequenceAs(alignTo, al, gap, preserveMappedGaps,
+ preserveUnmappedGaps) ? 1 : 0;
+ }
+ return count;
+ }
+
+ /**
+ * Returns the alignment in Fasta format. Behaviour of this method is not
+ * guaranteed between versions.
+ */
+ @Override
+ public String toString()
+ {
+ return new FastaFile().print(getSequencesArray());
+ }
+
+ /**
+ * Returns the set of distinct sequence names. No ordering is guaranteed.
+ */
+ @Override
+ public Set<String> getSequenceNames()
+ {
+ Set<String> names = new HashSet<String>();
+ for (SequenceI seq : getSequences())
+ {
+ names.add(seq.getName());
+ }
+ return names;
+ }
+
+ @Override
+ public boolean hasValidSequence()
+ {
+ boolean hasValidSeq = false;
+ for (SequenceI seq : getSequences())
+ {
+ if ((seq.getEnd() - seq.getStart()) > 0)