void AlignCheckCommand::help(){
try {
- //mothurOut("The remove.seqs command reads an .accnos file and one of the following file types: fasta, name, group or alignreport file.\n");
- //mothurOut("It outputs a file containing the sequences NOT in the .accnos file.\n");
- //mothurOut("The remove.seqs command parameters are accnos, fasta, name, group and alignreport. You must provide accnos and one of the other parameters.\n");
- //mothurOut("The remove.seqs command should be in the following format: remove.seqs(accnos=yourAccnos, fasta=yourFasta).\n");
- //mothurOut("Example remove.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n");
- //mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
+ mothurOut("The align.check command reads a fasta file and map file.\n");
+ mothurOut("It outputs a file containing the secondary structure matches in the .align.check file.\n");
+ mothurOut("The align.check command parameters are fasta and map, both are required.\n");
+ mothurOut("The align.check command should be in the following format: align.check(fasta=yourFasta, map=yourMap).\n");
+ mothurOut("Example align.check(map=silva.ss.map, fasta=amazon.fasta).\n");
+ mothurOut("Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n\n");
}
catch(exception& e) {
errorOut(e, "AlignCheckCommand", "help");
//get secondary structure info.
readMap();
-
+ ifstream in;
+ openInputFile(fastafile, in);
+
+ ofstream out;
+ string outfile = getRootName(fastafile) + "align.check";
+ openOutputFile(outfile, out);
+
+ out << "name" << '\t' << "pound" << '\t' << "dash" << '\t' << "plus" << '\t' << "equal" << '\t';
+ out << "loop" << '\t' << "tilde" << '\t' << "total" << endl;
+
+
+ while(!in.eof()){
+
+ Sequence seq(in);
+ statData data = getStats(seq.getAligned());
+
+ out << seq.getName() << '\t' << data.pound << '\t' << data.dash << '\t' << data.plus << '\t' << data.equal << '\t';
+ out << data.loop << '\t' << data.tilde << '\t' << data.total << endl;
+ }
+
+ in.close();
+ out.close();
return 0;
}
gobble(in);
}
in.close();
-
+
seqLength = structMap.size();
}
catch(exception& e) {
- errorOut(e, "AlignCheckCommand", "readFasta");
+ errorOut(e, "AlignCheckCommand", "readMap");
exit(1);
}
}
+/**************************************************************************************************/
+
+statData AlignCheckCommand::getStats(string sequence){
+ try {
+
+ statData data;
+ sequence = "*" + sequence; // need to pad the sequence so we can index it by 1
+
+ int seqLength = sequence.length();
+ for(int i=1;i<seqLength;i++){
+ if(structMap[i] != 0){
+ if(sequence[i] == 'A'){
+ if(sequence[structMap[i]] == 'T') { data.tilde++; }
+ else if(sequence[structMap[i]] == 'A') { data.pound++; }
+ else if(sequence[structMap[i]] == 'G') { data.equal++; }
+ else if(sequence[structMap[i]] == 'C') { data.pound++; }
+ else if(sequence[structMap[i]] == '-') { data.pound++; }
+ data.total++;
+ }
+ else if(sequence[i] == 'T'){
+ if(sequence[structMap[i]] == 'T') { data.plus++; }
+ else if(sequence[structMap[i]] == 'A') { data.tilde++; }
+ else if(sequence[structMap[i]] == 'G') { data.dash++; }
+ else if(sequence[structMap[i]] == 'C') { data.pound++; }
+ else if(sequence[structMap[i]] == '-') { data.pound++; }
+ data.total++;
+ }
+ else if(sequence[i] == 'G'){
+ if(sequence[structMap[i]] == 'T') { data.dash++; }
+ else if(sequence[structMap[i]] == 'A') { data.equal++; }
+ else if(sequence[structMap[i]] == 'G') { data.pound++; }
+ else if(sequence[structMap[i]] == 'C') { data.tilde++; }
+ else if(sequence[structMap[i]] == '-') { data.pound++; }
+ data.total++;
+ }
+ else if(sequence[i] == 'C'){
+ if(sequence[structMap[i]] == 'T') { data.pound++; }
+ else if(sequence[structMap[i]] == 'A') { data.pound++; }
+ else if(sequence[structMap[i]] == 'G') { data.tilde++; }
+ else if(sequence[structMap[i]] == 'C') { data.pound++; }
+ else if(sequence[structMap[i]] == '-') { data.pound++; }
+ data.total++;
+ }
+ else if(sequence[i] == '-'){
+ if(sequence[structMap[i]] == 'T') { data.pound++; data.total++; }
+ else if(sequence[structMap[i]] == 'A') { data.pound++; data.total++; }
+ else if(sequence[structMap[i]] == 'G') { data.pound++; data.total++; }
+ else if(sequence[structMap[i]] == 'C') { data.pound++; data.total++; }
+ else if(sequence[structMap[i]] == '-') { /*donothing*/ }
+ }
+ }
+ else if(isalnum(sequence[i])){
+ data.loop++;
+ data.total++;
+ }
+ }
+ return data;
+
+ }
+ catch(exception& e) {
+ errorOut(e, "AlignCheckCommand", "getStats");
+ exit(1);
+ }
+}
+
//**********************************************************************************************************************