+ added some docu
[qpalma.git] / dyn_prog / qpalma_dp.cpp
index a20af18..518591a 100644 (file)
@@ -246,10 +246,10 @@ void Alignment::myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
       delete[] matrices[i];
 }
 
-void Alignment::getAlignmentResults(int* s_align, int* e_align,
+void Alignment::getAlignmentResultsOld(int* s_align, int* e_align,
       int* mmatrix_p, double* alignscores, double* qScores) {
 
-   int idx;
+   size_t idx;
    for(idx=0; idx<splice_align_size; idx++)
       s_align[idx] = splice_align[idx];
 
@@ -285,7 +285,7 @@ void Alignment::getAlignmentResults(int* s_align, int* e_align,
    //printf("Leaving getAlignmentResults...\n");
 }
 
-void Alignment::getAlignmentArrays(int* dna_align, int* est_align) {
+void Alignment::getAlignmentArraysOld(int* dna_align, int* est_align) {
 
    int idx;
    for(idx=0; idx<result_len; idx++) {
@@ -293,3 +293,78 @@ void Alignment::getAlignmentArrays(int* dna_align, int* est_align) {
       est_align[idx] = EST_ARRAY[idx];
    }
 }
+
+
+PyObject* Alignment::getAlignmentResults() {
+
+   PyObject* result = PyTuple_New(5);
+   PyObject* py_splice_align  = PyList_New(splice_align_size);
+   PyObject* py_est_align     = PyList_New(est_align_size);
+   PyObject* py_mmatrix       = PyList_New(mmatrix_param_size);
+   PyObject* py_align_scores  = PyList_New(alignmentscores_size);
+   PyObject* py_q_scores      = PyList_New(0);
+
+   size_t idx;
+   for(idx=0; idx<splice_align_size; idx++)
+      PyList_SetItem(py_splice_align,idx,PyInt_FromLong(splice_align[idx]));
+   //s_align[idx] = splice_align[idx];
+
+   for(idx=0; idx<est_align_size; idx++)
+      PyList_SetItem(py_est_align,idx,PyInt_FromLong(est_align[idx]));
+
+   //e_align[idx] =  est_align[idx];
+
+   for(idx=0; idx<mmatrix_param_size; idx++)
+      PyList_SetItem(py_mmatrix,idx,PyInt_FromLong(mmatrix_param[idx]));
+
+   //mmatrix_p[idx] = mmatrix_param[idx];
+
+   for(idx=0; idx<alignmentscores_size; idx++)
+      PyList_SetItem(py_align_scores,idx,PyFloat_FromDouble(alignmentscores[idx]));
+
+   //alignscores[idx] = alignmentscores[idx];
+   
+   if (use_quality_scores) {
+      penalty_struct currentPlif;
+      int ctr=0;
+      for (int z=0; z<nr_paths; z++) {
+         for(int estChar=1;estChar<6;estChar++) {
+            for(int dnaChar=0;dnaChar<6;dnaChar++) {
+
+               int currentPos = (estChar-1)*6+dnaChar;
+               currentPlif = qualityFeaturesAllPaths[z][currentPos];
+
+               for(int pidx=0; pidx<currentPlif.len; pidx++) {
+                  //qScores[ctr] = currentPlif.penalties[pidx];
+                  //printf("%f ",qScores[ctr]);
+                  PyList_Append(py_q_scores,PyFloat_FromDouble(currentPlif.penalties[pidx]));
+                  ctr++;
+               }
+               //printf("\n");
+      }}}
+      //printf("\nctr is %d\n",ctr);
+   }
+
+   PyTuple_SetItem(result,0,py_splice_align);
+   PyTuple_SetItem(result,1,py_est_align);
+   PyTuple_SetItem(result,2,py_mmatrix);
+   PyTuple_SetItem(result,3,py_align_scores);
+   PyTuple_SetItem(result,4,py_q_scores);
+
+   return result;
+}
+
+PyObject* Alignment::getAlignmentArrays() {
+
+   PyObject* result = PyTuple_New(2);
+   PyObject* dna_align  = PyList_New(result_len);
+   PyObject* est_align  = PyList_New(result_len);
+
+   int idx;
+   for(idx=0; idx<result_len; idx++) {
+      PyList_SetItem(dna_align,idx,PyInt_FromLong(DNA_ARRAY[idx]));
+      PyList_SetItem(est_align,idx,PyInt_FromLong(EST_ARRAY[idx]));
+   }
+
+   return result;
+}