当前位置: 首页>>代码示例>>C++>>正文


C++ CommandLine::add_valid_parm方法代码示例

本文整理汇总了C++中CommandLine::add_valid_parm方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandLine::add_valid_parm方法的具体用法?C++ CommandLine::add_valid_parm怎么用?C++ CommandLine::add_valid_parm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandLine的用法示例。


在下文中一共展示了CommandLine::add_valid_parm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc,char **argv) {
 
  CommandLine *parms = CommandLine::Instance();

  parms->add_valid_parm("ref","Reference sequence for alignment");
  parms->add_valid_parm("seq","Sequences to align (fastq)");

  cout << "SmallAlign" << endl;
  cout << parms->usage() << endl; 

  parms->process_args (argc, argv);

  SmallAlign<> aligner(true);

  //Perform alignment, calculate error rate
  
  // Load reference sequence
  FastaReader<> reference_fastafile(parms->get_parm("ref"));
  bool openok = reference_fastafile.open();

  if(openok == false) cerr << "Could not open reference file: " << parms->get_parm("ref") << endl;
  else                cerr << "Opened reference file: " << parms->get_parm("ref") << endl;
  bool fasta_eof=false;

  if(openok) {
    for(;!fasta_eof;) {
      FastaSequence reference = reference_fastafile.next_sequence(fasta_eof);
      if(!fasta_eof) {
        // Forward and Reverse? (true/false)
        aligner.add_reference(reference.sequence,true);
      }
    }
  }
  
  FastPrbReader<BaseProbability<4> > sequences_fastq(parms->get_parm("seq"));

  openok=true;
  if(openok == false) cerr << "Could not open sequences file: " << parms->get_parm("seq") << endl;
  else                cerr << "Opened sequences file: " << parms->get_parm("seq") << endl;
  fasta_eof=false;
 

  int max_cycles=40;
  int max_quality=100;
  int printevery=1000;
  vector<int> errors_by_cycle(max_cycles,0);
  vector<int> errors_by_quality(max_quality,0);
  vector<int> quality_count(max_quality,0);
  vector<int> total_by_cycle (max_cycles,0);
  
  vector<int> errors_count(max_cycles,0);

  if(openok) {
    int n=0;
    for(;!sequences_fastq.eof();) {
      ProbabilitySequence<BaseProbability<4> > seq = sequences_fastq.get_sequence();
      
      SequenceAlignment<> alm;
      alm = aligner.align(seq.string_sequence());

      if(alm.score > 30)
      for(unsigned int m=0;m<alm.matchstring.size();m++) {
        if(alm.matchstring[m] == false) {
          errors_by_quality[seq.sequence()[m].max_probability()*max_quality]++;
          errors_by_cycle[m]++;
        }
        quality_count[seq.sequence()[m].max_probability()*max_quality]++;
        total_by_cycle[m]++;
      }
      errors_count[alm.score]++;

      if((n%printevery == 0) || sequences_fastq.eof()) {
        // Errors by cycle
        cout << "Error rates" << endl;
        for(int cycle=0;(cycle < max_cycles) && (total_by_cycle[cycle] > 0);cycle++) {
          cout << setw(5) << cycle << " ";
          cout << setw(10) << (static_cast<double>(errors_by_cycle[cycle])/static_cast<double>(total_by_cycle[cycle]))*100 << " ";
          cout << setw(10) << errors_by_cycle[cycle] << " ";
          cout << setw(10) << total_by_cycle[cycle] << endl;
        }
        cout << "Score count" << endl;
        for(int errs=0;(errs < max_cycles);errs++) {
          cout << setw(5) << errs << " ";
          cout << setw(10) << errors_count[errs] << endl;
        }
        
        // Errors by quality
        cout << "Error by quality" << endl;
        for(int quality=0;(quality < max_quality);quality++) {
          if(quality_count[quality] != 0) {
            cout << setw(5) << quality << " ";
            cout << setw(5) << errors_by_quality[quality] << " ";
            cout << setw(5) << quality_count[quality] << " ";
            cout << setw(10) << 1-(static_cast<double>(errors_by_quality[quality])/static_cast<double>(quality_count[quality])) << endl;
          }  
        }
      }
      n++;
    }
  } else {
//.........这里部分代码省略.........
开发者ID:emmaggie,项目名称:swift,代码行数:101,代码来源:prb_quality_table.cpp


注:本文中的CommandLine::add_valid_parm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。