]> git.donarmstrong.com Git - mothur.git/blobdiff - makecontigscommand.cpp
working of get.mimarkspackage and sra command
[mothur.git] / makecontigscommand.cpp
index 0bf56e7c2166daf33816de12216d318a5fba466b..15f002bffdbdc96e65ba18522955d500aa0fa8b0 100644 (file)
@@ -690,7 +690,7 @@ int MakeContigsCommand::createProcesses(vector< vector<string> > files, string o
                
                //loop through and create all the processes you want
                while (process != processors-1) {
-                       int pid = fork();
+                       pid_t pid = fork();
                        
                        if (pid > 0) {
                                processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
@@ -704,7 +704,7 @@ int MakeContigsCommand::createProcesses(vector< vector<string> > files, string o
                                        for(int i=0;i<tempFASTAFileNames.size();i++){
                                                for(int j=0;j<tempFASTAFileNames[i].size();j++){
                                                        if (tempFASTAFileNames[i][j] != "") {
-                                                               tempFASTAFileNames[i][j] += toString(getpid()) + ".temp";
+                                                               tempFASTAFileNames[i][j] += m->mothurGetpid(process) + ".temp";
                                                                m->openOutputFile(tempFASTAFileNames[i][j], temp);                      temp.close();
                                                        }
                                                }
@@ -712,14 +712,14 @@ int MakeContigsCommand::createProcesses(vector< vector<string> > files, string o
                                }
                 
                                num = driver(files[process], 
-                             outputFasta + toString(getpid()) + ".temp", 
-                             outputScrapFasta + toString(getpid()) + ".temp", 
-                             outputMisMatches + toString(getpid()) + ".temp",
+                             outputFasta + m->mothurGetpid(process) + ".temp",
+                             outputScrapFasta + m->mothurGetpid(process) + ".temp",
+                             outputMisMatches + m->mothurGetpid(process) + ".temp",
                              tempFASTAFileNames, process, group);
                                
                                //pass groupCounts to parent
                 ofstream out;
-                string tempFile = toString(getpid()) + ".num.temp";
+                string tempFile = m->mothurGetpid(process) + ".num.temp";
                 m->openOutputFile(tempFile, out);
                 out << num << endl;
                                if (createFileGroup || createOligosGroup) {
@@ -1042,7 +1042,9 @@ int MakeContigsCommand::driver(vector<string> files, string outputFasta, string
             if (seq2End < overlapEnd) { overlapEnd = seq2End; }  //smallest end position is where overlapping ends
             
             int oStart = contig.length();
+            //cout << fSeq.getAligned()  << endl; cout << rSeq.getAligned() << endl;
             for (int i = overlapStart; i < overlapEnd; i++) {
+                //cout << seq1[i] << ' ' << seq2[i] << ' ' << scores1[ABaseMap[i]] << ' ' << scores2[BBaseMap[i]] << endl;
                 if (seq1[i] == seq2[i]) { //match, add base and choose highest score
                     contig += seq1[i];
                 }else if (((seq1[i] == '.') || (seq1[i] == '-')) && ((seq2[i] != '-') && (seq2[i] != '.'))) { //seq1 is a gap and seq2 is a base, choose seq2, unless quality score for base is below insert. In that case eliminate base
@@ -1076,7 +1078,8 @@ int MakeContigsCommand::driver(vector<string> files, string outputFasta, string
             }else { //seq2 ends before seq1 so take from overlap to length from seq1
                 for (int i = overlapEnd; i < length; i++) {  contig += seq1[i]; }
             }
-            
+            //cout << contig << endl;
+            //exit(1);
             if (trimOverlap) { contig = contig.substr(overlapStart-1, oend-oStart);  if (contig.length() == 0) { trashCode += "l"; } }
             
             if(trashCode.length() == 0){
@@ -1140,7 +1143,7 @@ int MakeContigsCommand::driver(vector<string> files, string outputFasta, string
             num++;
             
                        //report progress
-                       if((num) % 1000 == 0){  m->mothurOut(toString(num)); m->mothurOutEndLine();             }
+                       if((num) % 1000 == 0){  m->mothurOutJustToScreen(toString(num)); m->mothurOutEndLine();         }
                }
         
                //report progress
@@ -1286,7 +1289,7 @@ vector< vector<string> > MakeContigsCommand::readFastqFiles(unsigned long int& c
                     count++;
                     
                     //report progress
-                    if((count) % 10000 == 0){  m->mothurOut(toString(count)); m->mothurOutEndLine();           }
+                    if((count) % 10000 == 0){  m->mothurOutJustToScreen(toString(count)); m->mothurOutEndLine();               }
                 //}
             }
                }
@@ -1295,9 +1298,11 @@ vector< vector<string> > MakeContigsCommand::readFastqFiles(unsigned long int& c
         
         if (uniques.size() != 0) {
             for (itUniques = uniques.begin(); itUniques != uniques.end(); itUniques++) {
+                if (m->control_pressed) { break; }
                 m->mothurOut("[WARNING]: did not find paired read for " + itUniques->first + ", ignoring.\n");
             }
             for (map<string, pairFastqRead>:: iterator it = pairUniques.begin(); it != pairUniques.end(); it++) {
+                if (m->control_pressed) { break; }
                 m->mothurOut("[WARNING]: did not find paired read for " + (it->first).substr(1) + ", ignoring.\n");
             }
             m->mothurOutEndLine();
@@ -1657,6 +1662,7 @@ fastqRead MakeContigsCommand::readFastq(ifstream& in, bool& ignore){
         
         vector<int> qualScores = convertQual(quality);
         
+        m->checkName(name);
         read.name = name;
         read.sequence = sequence;
         read.scores = qualScores;
@@ -1971,7 +1977,6 @@ bool MakeContigsCommand::getOligos(vector<vector<string> >& fastaFileNames, stri
                     else { uniquePrimers.insert(tempPair); }
                                        
                     if (m->debug) {  if (group != "") { m->mothurOut("[DEBUG]: reading group " + group + ".\n"); }else{ m->mothurOut("[DEBUG]: no group for primer pair " + newPrimer.forward + " " + newPrimer.reverse + ".\n"); }  }
-                    
                                        primers[indexPrimer]=newPrimer; indexPrimer++;          
                                        primerNameVector.push_back(group);
                                }else if(type == "BARCODE"){