Permalink
Browse files

Adds file mismatch check to summary.seqs

  • Loading branch information...
1 parent 931b05c commit 4f70931e1fb5f5f787c3cec6db0be3922e53388f @mothur-westcott mothur-westcott committed Jan 26, 2017
Showing with 14 additions and 2 deletions.
  1. +14 −2 source/commands/seqsummarycommand.cpp
@@ -197,18 +197,20 @@ int SeqSummaryCommand::execute(){
long long numSeqs = 0;
long long size = 0;
+ long long numUniques = 0;
map<int, long long> startPosition;
map<int, long long> endPosition;
map<int, long long> seqLength;
map<int, long long> ambigBases;
map<int, long long> longHomoPolymer;
- if (namefile != "") { nameMap = m->readNames(namefile); }
+ if (namefile != "") { nameMap = m->readNames(namefile); numUniques = nameMap.size(); }
else if (countfile != "") {
CountTable ct;
ct.readTable(countfile, false, false);
nameMap = ct.getNameMap();
size = ct.getNumSeqs();
+ numUniques = ct.getNumUniqueSeqs();
}
if (m->control_pressed) { return 0; }
@@ -244,9 +246,19 @@ int SeqSummaryCommand::execute(){
//set size
if (countfile != "") {}//already set
- else if (namefile == "") { size = numSeqs; }
+ else if (namefile == "") { size = numSeqs; }
else { for (map<int, long long>::iterator it = startPosition.begin(); it != startPosition.end(); it++) { size += it->second; } }
+ if ((namefile != "") || (countfile != "")) {
+ string type = "count";
+ if (namefile != "") { type = "name"; }
+ if (numSeqs != numUniques) { // do fasta and name/count files match
+ m->mothurOut("[ERROR]: Your " + type + " file contains " + toString(numUniques) + " unique sequences, but your fasta file contains " + toString(numSeqs) + ". File mismatch detected, quitting command.\n"); m->control_pressed = true;
+ }
+ }
+
+ if (m->control_pressed) { m->mothurRemove(summaryFile); return 0; }
+
long long ptile0_25 = 1+(long long)(size * 0.025); //number of sequences at 2.5%
long long ptile25 = 1+(long long)(size * 0.250); //number of sequences at 25%
long long ptile50 = 1+(long long)(size * 0.500);

0 comments on commit 4f70931

Please sign in to comment.