コード例 #1
0
ファイル: cmdlinetest.cpp プロジェクト: pjohansson/gromacs
void CommandLine::merge(const CommandLine &args)
{
    // Skip first argument if it is the module name.
    const int firstArg = (args.arg(0)[0] == '-' ? 0 : 1);
    for (int i = firstArg; i < args.argc(); ++i)
    {
        append(args.arg(i));
    }
}
コード例 #2
0
ファイル: moduletest.cpp プロジェクト: hasagar/gromacs
void
AbstractTrajectoryAnalysisModuleTestFixture::runTest(const CommandLine &args)
{
    TrajectoryAnalysisModule &module = impl_->module();
    // Skip first argument if it is the module name.
    int firstArg = (args.arg(0)[0] == '-' ? 0 : 1);
    for (int i = firstArg; i < args.argc(); ++i)
    {
        impl_->cmdline_.append(args.arg(i));
    }

    TestReferenceChecker rootChecker(impl_->data_.rootChecker());

    rootChecker.checkString(args.toString(), "CommandLine");

    if (!impl_->outputDatasets_.empty())
    {
        TestReferenceChecker               dataChecker(
                rootChecker.checkCompound("OutputData", "Data"));
        Impl::DatasetNames::const_iterator dataset;
        for (dataset = impl_->outputDatasets_.begin();
             dataset != impl_->outputDatasets_.end();
             ++dataset)
        {
            const char           *name    = dataset->c_str();
            AbstractAnalysisData &dataset = module.datasetFromName(name);
            AnalysisDataTestFixture::addReferenceCheckerModule(
                    dataChecker, name, &dataset);
        }
    }

    TrajectoryAnalysisCommandLineRunner runner(&module);
    runner.setPrintCopyright(false);
    int rc = 0;
    EXPECT_NO_THROW_GMX(rc = runner.run(impl_->cmdline_.argc(), impl_->cmdline_.argv()));
    EXPECT_EQ(0, rc);

    if (!impl_->outputFiles_.empty())
    {
        TestReferenceChecker                 outputChecker(
                rootChecker.checkCompound("OutputFiles", "Files"));
        Impl::OutputFileList::const_iterator outfile;
        for (outfile = impl_->outputFiles_.begin();
             outfile != impl_->outputFiles_.end();
             ++outfile)
        {
            std::string output = File::readToString(outfile->path);
            outputChecker.checkStringBlock(output, outfile->option.c_str());
        }
    }
}
コード例 #3
0
ファイル: delete-target-gaps.C プロジェクト: bmajoros/PhyLib
int Application::main(int argc,char *argv[])
{
  // Process command line
  cmd=new CommandLine(argc,argv,"");
  if(cmd->numArgs()!=2)
    throw String("\ndelete-target-gaps <in.maf> <target-name>\n");
  String mafFile=cmd->arg(0);
  String targetName=cmd->arg(1);
  
  // Setting up alphabet
  alphabet=&DnaDashDotAlphabet::global();
  gapSymbols.addMember(alphabet->lookup('-'));
  gapSymbols.addMember(alphabet->lookup('.'));
  gapSymbols.addMember(alphabet->lookup('N'));
  alphabetMap=new DropGapMapping(*alphabet,PureDnaAlphabet::global());
  
  // Load the alignments
  //int rootID=phylogeny->getRoot()->getID();
  alignment=NULL;
  ifstream is(mafFile.c_str());
  if(!is.good()) throw String("Can't open file ")+mafFile;
  while(!is.eof()) {
    MultiAlignment *a=new MultiAlignment;
    a->loadMAF(is);
    if(a->getNumTracks()>0) {
      a->toupper();
      MultSeqAlignment *m=new MultSeqAlignment(*a,*alphabet,gapSymbols);
      int rootID=m->getTrackByName(targetName).getID();
      m->deleteTargetGaps(rootID);
      if(!alignment) alignment=m;
      else {
	alignment->append(*m);
	delete m;
      }
    }
    delete a;
  }
  is.close();

  // Emit the processed alignment
  alignment->printSlice(cout,0,alignment->getLength(),'+',60);

  return 0;
}