import java.util.Hashtable;
import java.util.List;
-
/**
* extraction of processing routines to allow mocking
*
* @throws Exception
*/
public static Object[] processJnetResult(AlignmentI currentView,
- AlignmentView input,
- char gapChar, Hashtable SequenceInfo,
+ AlignmentView input, char gapChar, Hashtable SequenceInfo,
boolean msaPred, int[] predMap, String result_PredFile,
String result_Aligfile, FileParse full_alignment)
throws Exception
* @param profileseq
*/
public static void insertHiddenResidues(AlignmentI al, char gc,
- int[] predMap,
- SequenceI origseq)
+ int[] predMap, SequenceI origseq)
{
// orig: asdfPPPPPPPasdfPPPPasdf
// pred: PPPPPPPPPPP
// al: asdf-----P-P-P---P---P----P---Pasdf-P--PP---P---asdf
// s1: ....SSSSSSS-SS---S---SSSSSS---S....-S--SSSSSSSSS....
// s2: ....SSSSSSS-SSSSSSSSSSS----SSS-....S-SSS-----SSS....
+
+ // iteration 0: add asdf, append -----P
+ // iteration 1: append -P
+ // iteration 2: append -P
+ // iteration 3: append ---P
+ // iteration 4: append ---P
+ // iteration 5: append ----P
+ // iteration 6: append ---P
+ // iteration 7: append -P
+ // iteration 8: append P
+ // iteration 9: append P
+ // iteration 10: append ---P
+ // tail: append: ---, add asdf
+
String alseq = "";
- int lsp = 0;
SequenceI predseq = al.getSequenceAt(0);
int predIdx = 0; // next column of prediction to preserve
// positions in original and prediction sequence
- int lp = origseq.getStart(), predPos = predseq.getStart();
+ int lp = origseq.getStart() - 1, predPos = predseq.getStart();
for (int r = 0; r < predMap.length; r++)
{
// also need to keep track of trimmed prediction sequence numbering
{
// hidden region insert from origseq
String insert = origseq.getSequenceAsString(
- origseq.findIndex(lp) - 1,
+ origseq.findIndex(lp + 1) - 1,
origseq.findIndex(predMap[r]) - 1);
insertGapsAt(al, gc, alseq.length(), insert.length());
}
// Now update prediction sequence for next position.
{
- int predIdxNext = predseq.findIndex(predPos + 1) - 1;
+ int predIdxNext = predseq.findIndex(predPos); // everything up
+ // to the current
+ // position in the
+ // prediction
+ // sequence
+ // alignment
if (predIdxNext <= predIdx)
{
predIdxNext = predseq.getLength();
predPos++;
}
// append final bits
+ // add any remaining gaps
+ {
+ int predIdxNext = predseq.findIndex(predPos); // everything up
+ // to the current
+ // position in the
+ // prediction
+ // sequence
+ // alignment
+ if (predIdxNext <= predIdx)
+ {
+ predIdxNext = predseq.getLength();
+ }
+ // just add in next segment of predseq
+ String predsert = predseq.getSequenceAsString(predIdx, predIdxNext);
+ alseq += predsert;
+ predIdx = predIdxNext;
+ }
+
if (lp < origseq.getEnd())
{
String insert = origseq.getSequenceAsString(
- origseq.findIndex(lp) - 1, origseq.getLength());
+ origseq.findIndex(lp + 1) - 1, origseq.getLength());
insertGapsAt(al, gc, alseq.length(), insert.length());
alseq += insert;
}
{
if (gapMap[r] - lp > 1)
{
- insertGapsAt(al, gc, gapMap[r], gapMap[r]-lp);
+ insertGapsAt(al, gc, gapMap[r], gapMap[r] - lp);
}
lp = gapMap[r];
}