[project @ 13]
[mussa.git] / sequence.cc
index c706f47cbface27d21c4117ab8696c5a95158bb6..4351f8915bf528a9c350b11f0f343fe0ef30f51e 100644 (file)
@@ -1,3 +1,23 @@
+//  This file is part of the Mussa source distribution.
+//  http://mussa.caltech.edu/
+//  Contact author: Tristan  De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA.  It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
+//  This file is part of the Mussa source distribution.
+//  http://mussa.caltech.edu/
+//  Contact author: Tristan  De Buysscher, tristan@caltech.edu
+
+// This program and all associated source code files are Copyright (C) 2005
+// the California Institute of Technology, Pasadena, CA, 91125 USA.  It is
+// under the GNU Public License; please see the included LICENSE.txt
+// file for more information, or contact Tristan directly.
+
+
 //                        ----------------------------------------
 //                           ---------- sequence.cc -----------
 //                        ----------------------------------------
@@ -301,6 +321,7 @@ void
 Sequence::set_seq(string a_seq)
 {
   sequence = a_seq;
+  length = sequence.length();
 }
 
 
@@ -543,15 +564,19 @@ Sequence::find_motif(string a_motif)
 
   cout << "motif is: " << a_motif << endl;
   a_motif = motif_validate(a_motif);
-  cout << "motif is: " << a_motif << endl;
+  //cout << "motif is: " << a_motif << endl;
 
-  motif_scan(a_motif, &motif_match_starts);
 
-  a_motif_rc = rc_motif(a_motif);
-  // make sure not to do search again if it is a palindrome
-  if (a_motif_rc != a_motif)
-    motif_scan(a_motif_rc, &motif_match_starts);
+  if (a_motif != "")
+  {
+    cout << "Sequence: none blank motif\n";
+    motif_scan(a_motif, &motif_match_starts);
 
+    a_motif_rc = rc_motif(a_motif);
+    // make sure not to do search again if it is a palindrome
+    if (a_motif_rc != a_motif)
+      motif_scan(a_motif_rc, &motif_match_starts);
+  }
   return motif_match_starts;
 }
 
@@ -563,6 +588,7 @@ Sequence::motif_scan(string a_motif, vector<int> * motif_match_starts)
 
   // faster to loop thru the sequence as a old c string (ie char array)
   seq_c = (char*)sequence.c_str();
+  //cout << "Sequence: motif, seq len = " << sequence.length() << endl; 
   motif_len = a_motif.length();
 
   //cout << "motif_length: " << motif_len << endl;
@@ -570,12 +596,13 @@ Sequence::motif_scan(string a_motif, vector<int> * motif_match_starts)
 
   motif_i = 0;
 
-  cout << "motif: " << a_motif << endl;
+  //cout << "motif: " << a_motif << endl;
 
-  //cout << "length: " << length << endl;
+  //cout << "Sequence: motif, length= " << length << endl;
   seq_i = 0;
   while (seq_i < length)
   {
+    cout << seq_c[seq_i];
     //if ((seq_i > 10885) && (seq_i < 10917))
     //cout << seq_c[seq_i] << "?" << a_motif[motif_i] << ":" << motif_i << " ";
     // this is pretty much a straight translation of Nora's python code