String type;
+ private int[] charToInt;
+
/**
* Creates a new AlignSeq object.
*
if (type.equals(AlignSeq.PEP))
{
intToStr = pep;
+ charToInt = ResidueProperties.aaIndex;
defInt = 23;
}
else if (type.equals(AlignSeq.DNA))
{
intToStr = dna;
+ charToInt = ResidueProperties.nucleotideIndex;
defInt = 4;
}
else
public int[] stringToInt(String s, String type)
{
int[] seq1 = new int[s.length()];
-
for (int i = 0; i < s.length(); i++)
{
// String ss = s.substring(i, i + 1).toUpperCase();
try
{
- if (type.equals("pep"))
- {
- seq1[i] = ResidueProperties.aaIndex[c];
- if (seq1[i] > 23)
- {
- seq1[i] = 23;
- }
- }
- else if (type.equals("dna"))
+ seq1[i] = charToInt[c]; // set accordingly from setType
+ if (seq1[i]<0 || seq1[i] > defInt) // set from setType: 23 for peptides, or 4 for NA.
{
- seq1[i] = ResidueProperties.nucleotideIndex[c];
- if (seq1[i] > 4)
- {
- seq1[i] = 4;
- }
+ seq1[i] = defInt;
}
} catch (Exception e)
{
- if (type.equals("dna"))
- {
- seq1[i] = 4;
- }
- else
- {
- seq1[i] = 23;
- }
+ seq1[i] = defInt;
}
}