X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=secondarystructurecommand.cpp;h=7156082f8b1b43228a62c6cf93abec9f2d900109;hb=cc1838f288a7712d44929fca5175ce89f3a58f12;hp=48ea1549aa78537966745dbe11fbc9d1afbf8f51;hpb=462fca6d24fd15ca035358ff70bcfae52c3281c3;p=mothur.git diff --git a/secondarystructurecommand.cpp b/secondarystructurecommand.cpp index 48ea154..7156082 100644 --- a/secondarystructurecommand.cpp +++ b/secondarystructurecommand.cpp @@ -55,12 +55,12 @@ AlignCheckCommand::AlignCheckCommand(string option){ 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"); @@ -78,7 +78,28 @@ int AlignCheckCommand::execute(){ //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; } @@ -104,7 +125,7 @@ void AlignCheckCommand::readMap(){ gobble(in); } in.close(); - + seqLength = structMap.size(); @@ -120,9 +141,74 @@ void AlignCheckCommand::readMap(){ } 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