*/
public static int alignProteinAsDna(AlignmentI protein, AlignmentI dna)
{
+ List<SequenceI> unmappedProtein = new ArrayList<SequenceI>();
+ unmappedProtein.addAll(protein.getSequences());
+
Set<AlignedCodonFrame> mappings = protein.getCodonFrames();
/*
{
addCodonPositions(dnaSeq, prot, protein.getGapCharacter(),
seqMap, alignedCodons);
+ unmappedProtein.remove(prot);
}
}
}
- return alignProteinAs(protein, alignedCodons);
+ return alignProteinAs(protein, alignedCodons, unmappedProtein);
}
/**
* @param alignedCodons
* an ordered map of codon positions (columns), with sequence/peptide
* values present in each column
+ * @param unmappedProtein
* @return
*/
protected static int alignProteinAs(AlignmentI protein,
- Map<AlignedCodon, Map<SequenceI, String>> alignedCodons)
+ Map<AlignedCodon, Map<SequenceI, String>> alignedCodons,
+ List<SequenceI> unmappedProtein)
{
/*
* Prefill aligned sequences with gaps before inserting aligned protein
String allGaps = String.valueOf(gaps);
for (SequenceI seq : protein.getSequences())
{
- seq.setSequence(allGaps);
+ if (!unmappedProtein.contains(seq))
+ {
+ seq.setSequence(allGaps);
+ }
}
int column = 0;
SequenceI prot1 = new Sequence("Seq1", "CHYQ");
SequenceI prot2 = new Sequence("Seq2", "CHYQ");
SequenceI prot3 = new Sequence("Seq3", "CHYQ");
+ SequenceI prot4 = new Sequence("Seq4", "R-QSV"); // unmapped, unchanged
AlignmentI protein = new Alignment(new SequenceI[]
- { prot1, prot2, prot3 });
+ { prot1, prot2,
+ prot3, prot4 });
protein.setDataset(null);
MapList map = new MapList(new int[]
assertEquals("C-H--Y-Q-", prot1.getSequenceAsString());
assertEquals("-C--H-Y-Q", prot2.getSequenceAsString());
assertEquals("C--H--Y-Q", prot3.getSequenceAsString());
+ assertEquals("R-QSV", prot4.getSequenceAsString());
}
/**