Esempio n. 1
0
bool Application::match(const String &pattern,EmissionSequence &S,
			int begin,int len)
{
  int end=begin+len;
  for(int i=begin ; i<end ; ++i)
    if(S[i].getDiscrete(0)!=alphabet.lookup(pattern[i-begin])) return false;
  return true;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
void Application::loadIntergenic(const BOOM::String &filename)
{
  Alphabet &alphabet=DnaAlphabet::global();
  ContentSensor *fullModel=ContentSensor::load(filename);
  char base[2];
  base[1]='\0';

  for(int s=0 ; s<5 ; ++s)
    {
      base[0]=alphabet.lookup(s);
      Sequence seq(base,alphabet);
      intergenicModel[s]=
	fullModel->scoreSingleBase(seq,BOOM::String(base),0,seq[0],base[0]);
    }
  delete fullModel;
}
Esempio n. 4
0
void Application::writeOutput(const BOOM::String &tataFile,
			      const BOOM::String &outfile)
{
  // Load TATA model
  SignalSensor *tata=SignalSensor::load(tataFile,GC);

  // Create output file and write header
  ofstream os(outfile.c_str());
  os.precision(8);
  os<<"TataCapModel"<<endl;
  os<<minSeparation<<"\t"<<maxSeparation<<endl;
  
  // Write out the TATA model
  tata->save(os);

  // Write out the intergenic model
  Alphabet &alphabet=DnaAlphabet::global();
  os<<"MC\nINTERGENIC\n0\t0\t1\n5"<<endl;
  os<<"A\n"<<intergenicModel[alphabet.lookup('A')]<<endl;
  os<<"C\n"<<intergenicModel[alphabet.lookup('C')]<<endl;
  os<<"G\n"<<intergenicModel[alphabet.lookup('G')]<<endl;
  os<<"N\n"<<intergenicModel[alphabet.lookup('N')]<<endl;
  os<<"T\n"<<intergenicModel[alphabet.lookup('T')]<<endl;
  os<<"MC\nINTERGENIC\n0\t0\t1\n5"<<endl;
  os<<"A\n"<<intergenicModel[alphabet.lookup('T')]<<endl;
  os<<"C\n"<<intergenicModel[alphabet.lookup('G')]<<endl;
  os<<"G\n"<<intergenicModel[alphabet.lookup('C')]<<endl;
  os<<"N\n"<<intergenicModel[alphabet.lookup('N')]<<endl;
  os<<"T\n"<<intergenicModel[alphabet.lookup('A')]<<endl;

  // Write out the CAP model
  capModel->save(os);

  // Write out the CAP/intergenic ratio model
  capIntergenicRatioModel->save(os);
}