Exemplo n.º 1
0
 Playlist(int count, const char *const aSongs[]) : mStream(0), mSource(0)
 {
     for (int i = 0; i < count; ++i) {
         mSongs.push_back(aSongs[i]);
     }
     mCurrentSong = mSongs.begin();
     Init();
 }
Exemplo n.º 2
0
// correct MD sepearte list
// also collect deletion base list
string correctMDstring(numList MDnum, stringList MDLetter, stringList &deletions)
{
    string MDList;
    int i = 0;
    //make deletion list
    for (int i = 0; i < MDnum.size(); i ++)
    {
        if (MDLetter[i][0] == '^')
        {
            deletions.push_back(MDLetter[i]);
        }
    }
    MDList  = creatMDstring(MDnum,MDLetter);
    return MDList;
}
Exemplo n.º 3
0
	//Split states into individual state strings
    bool PWM::_splitPositions(std::string& txt ,stringList& sts){
        
        size_t start=0;
        size_t end=0;
        
        while(start!=std::string::npos){
            end=txt.find("NAME:",start+1);
            
            std::string st = txt.substr(start,end-start);
            
            clear_whitespace(st, "#><");
            
			sts.push_back(st);
			
            start=txt.find("NAME:",end);
            
        }
        return true;
    }
Exemplo n.º 4
0
	//Get all Name in order
	bool PWM::_getOrderedPositionNames(stringList& pos, stringList& names){
        
		for(size_t i=0;i<pos.size();i++){
            size_t nameHeader=pos[i].find("NAME:");
			if (nameHeader == std::string::npos){
				continue;
			}
            size_t nameLineEnding=pos[i].find_first_of("\n",nameHeader);
            std::string name = pos[i].substr(nameHeader+5,nameLineEnding-(nameHeader+5));
            clear_whitespace(name, " \t\n");
            if (names.contains(name)){
                std::cerr << "Position with name of: " << name << " is defined twice in the model\n";
                return false;
            }
            else{
                names.push_back(name);
            }
        }
        return true;
    }
Exemplo n.º 5
0
// Fix sequence, MDline, cigarLine
// i.  collect clipped bases
// ii.  collect insertion bases
// iii. remove insertion bases on 
//      1. query sequence and 
//      2. cigar line
// iv. count mismatch pattern (e.g. AtoG, GtoT)
stringList insertionAndMismatch(string cigarLine, string MDline, string sequence, stringList &insertion, 
                                string &softclippedHead, string &softclippedTail, string id, int numOfMis)
{
    stringList mismatchList(numOfMis);
    string fixedCigarLine, fixedSeq, mismatch, ref, read;
    int mis, i = 0, size = cigarLine.length();
    while( i < size)
    {
        if (cigarLine.at(i) == 'S')
        {
            if (i == 0)
            {
                while ( cigarLine.at(i) == 'S')
                {
                    i ++ ;
                }
				softclippedHead = sequence.substr(0,i);
            }
            else
            {
                softclippedTail = sequence.substr(i,size-i);
                i += size;
            }
        }
        else if (cigarLine.at(i) == 'I')
        {
            insertion.push_back(string(1,sequence[i]));
            i ++;
        }
        else
        {
            fixedCigarLine.push_back(cigarLine[i]);
            fixedSeq.push_back(sequence[i]);
            i ++;
        }
    }
	/*
    //debugging    
    cerr << fixedCigarLine << endl;
    cerr << MDline << endl;
    cerr << fixedSeq  <<endl;
    cerr << sequence << endl ;
    cerr << cigarLine << endl;
    cerr << softclippedHead << '\t' << softclippedTail << endl;
	*/
    //assertion
    assert(fixedCigarLine.length() == MDline.length());
    assert(fixedSeq.length() == MDline.length());
    
    //extract misincorporations
    mis = 0;
    for (int i = 0; i < fixedCigarLine.length(); i++)
    {
        if (fixedCigarLine.at(i) == 'M' && MDline.at(i) != '=')
        {
            ref = MDline.substr(i,1) ;
            read = fixedSeq.substr(i,1);
            assert (ref != read);
            mismatch = ref +"to"+ read;
            mismatchList[mis] = mismatch;
            mis ++;
        }
    }
    return mismatchList;
}