コード例 #1
0
ファイル: main.cpp プロジェクト: AugRob/OALWrapper
 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();
 }
コード例 #2
0
ファイル: main.cpp プロジェクト: AugRob/OALWrapper
 Playlist(const stringList& aSongs) :
                                     mStream(0),
                                     mSource(0),
                                     mThreadAlive(false)
 {
     mSongs.assign(aSongs.begin(), aSongs.end());
     mCurrentSong = mSongs.begin();
     Init();
 }
コード例 #3
0
ファイル: pwm.cpp プロジェクト: B-Rich/StochHMM
	//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;
    }
コード例 #4
0
ファイル: evamemo.cpp プロジェクト: MagicGroup/eva
void EvaMemoReplyPacket::setMemo( const stringList &infos )
{
	m_Memo.name = infos.at(0);
	m_Memo.mobile = infos.at(1);
	m_Memo.telephone = infos.at(2);
	m_Memo.address = infos.at(3);
	m_Memo.email = infos.at(4);
	m_Memo.zipcode = infos.at(5);
	m_Memo.note = infos.at(6);
}
コード例 #5
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;
}
コード例 #6
0
ファイル: pwm.cpp プロジェクト: B-Rich/StochHMM
	//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;
    }
コード例 #7
0
// extract from each line different columns
// and give them to further processing
int processLine(stringList columns, int qualThreshold, int covThreshold, int &seqCount) 
{
    string transcriptID, pos, refbase, reads, baseQuals;
    int cov;
    if (columns.size() == 6) 
    {
        cov = atoi(columns[3].c_str());
        refbase = columns[2];
        if (cov > covThreshold)
        { 
            transcriptID = columns[0];
            pos = columns[1];
            reads = columns[4];
            baseQuals = columns[5];
            assert (baseQuals.length() == cov) ;
			extractMismatches(reads,baseQuals,cov, transcriptID,pos,refbase, qualThreshold, seqCount);
        }
    }
    return 0;
}
コード例 #8
0
// extract from each line different columns
// and give them to further processing
void processLine( stringList columns, int qualThreshold, int coverageThreshold) 
{
    if (columns[2] != "N" && columns[2] != "." && columns[2] != "_" )
    {
        string transcriptID, pos, ref, reads, baseQuals;
        int cov;
        if (columns.size() == 6) 
        {
            cov = atoi(columns[3].c_str());
            if (cov > coverageThreshold)
            { 
                transcriptID = columns[0];
                pos = columns[1];
                ref = columns[2];
                reads = columns[4];
                baseQuals = columns[5];
                assert ( baseQuals.length() == cov ) ;
				extractMismatches(reads, baseQuals, cov, transcriptID, 
								pos, ref, qualThreshold, coverageThreshold);
            }
        }
    }
}
コード例 #9
0
//define extra field
int findField(stringList columns,string &XGfield, 
                string &NMfield, string &MDfield)
{
    int i;
    string field;
    for (i = 10 ; i < columns.size(); i++)
    {
        field = columns[i];
        if (field.substr(0,2) == "XG")
        {
            XGfield = field;
        }
        else if (field.substr(0,2) == "NM")
        {
            NMfield = field;
        }
        else if (field.substr(0,2) == "MD")
        {
            MDfield = field;
        }
    }
    return 0;
}
コード例 #10
0
ファイル: externalFuncs.cpp プロジェクト: vohoaiviet/stochhmm
//!Parse the stringList from model import
bool transitionFuncParam::parse(stringList& lst, tracks& trcks, weights* wts, StateFuncs* funcs) {

    size_t idx;

    //FUNCTION NAME (REQUIRED)
    if (lst.contains("FUNCTION")) {
        idx=lst.indexOf("FUNCTION");
        idx++;
        transFuncName = lst[idx];
        if (funcs!=NULL) {
            transFunc = funcs->getTransitionFunction(transFuncName);
        }
    }
    else {
        std::cerr << "Tag was parsed but contains no FUNCTION: . Please check the formatting of the tags\n" << std::endl;
        return false;

        //errorInfo(sCantParseLine, "Tag was parsed but contains no FUNCTION: . Please check the formatting of the tags\n");
    }

    //Implement Which track to pass to function

    if (lst.contains("TRACK")) {
        idx=lst.indexOf("TRACK");
        idx++;
        trackName=lst[idx];
        transFuncTrack = trcks.getTrack(trackName);
    }
    else {
        std::cerr << "Tag was parsed but contains no TRACK: . Please check the formatting of the tags\n" << std::endl;
        return false;
        //errorInfo(sCantParseLine, "Tag was parsed but contains no TRACK: . Please check the formatting of the tags\n");
    }



    if (lst.contains("SCALE")) {
        idx=lst.indexOf("SCALE");
        idx++;
        if (isNumeric(lst[idx])) {
            transFuncScaling = new(std::nothrow) weight;

            if (transFuncScaling==NULL) {
                std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
                exit(1);
            }

            double tempValue;
            if (!stringToDouble(lst[idx], tempValue)) {
                std::cerr << "Ambiguous Value couldn't be parsed: "<< lst[idx] << std::endl;
                return false;
            }

            transFuncScaling->setAbsolute(tempValue);
        }
        else {
            std::string weightName=lst[idx];
            if (wts->count(weightName)) {
                transFuncScaling = (*wts)[weightName];
            }
        }

    }


    //Process Traceback Commands

    //Parse the TO Traceback Labels in the function tag
    const std::string tbLabels[]= {"TO_LABEL","TB->LABEL","TO_GFF","TB->GFF","TO_STATE","TB->STATE","TO_START","TB->START","DIFF_STATE"};
    const tracebackIdentifier typs[]= {STATE_LABEL,STATE_LABEL,STATE_GFF,STATE_GFF,STATE_NAME,STATE_NAME,START_INIT,START_INIT,DIFF_STATE};

    for(int i=0; i<9; i++) {
        if (lst.contains(tbLabels[i])) {

            transFuncTraceback=true;

            idx=lst.indexOf(tbLabels[i]);
            transFuncTracebackIdentifier=typs[i];

            if (typs[i]!=START_INIT || typs[i]!=DIFF_STATE) {
                transFuncTracebackString=lst[idx+1];
            }
        }
    }


    // Parse the Combine tags
    if (transFuncTraceback) {
        //Process Traceback Combining Commands
        std::string combineLabels[] = {"COMBINE_LABEL","COMBINE_GFF","COMBINE_STATE", "NO_COMBINE"};
        const combineIdentifier comtyps[] = {STATELABEL,STATEGFF,STATENAME,FULL};
        bool combineTypeProvided=false;
        for(int i=0; i<4; i++) {
            if (lst.contains(combineLabels[i])) {
                idx=lst.indexOf(combineLabels[i]);
                transFuncCombineIdentifier=comtyps[i];
                transFuncCombineString=lst[idx+1];
                combineTypeProvided=true;
            }
        }

        if (!combineTypeProvided) {
            std::cerr << "Transition Function tag with a traceback was called, but no CombineType was provided.  If no traceback is needed then please remove traceback command. \n" << std::endl;
            return false;

            //errorInfo(sTagIncorrect, "Transition Function tag with a traceback was called, but no CombineType was provided.  If no traceback is needed then please remove traceback command. \n");
        }
    }


    return true;
}
コード例 #11
0
ファイル: externalFuncs.cpp プロジェクト: vohoaiviet/stochhmm
//!Parse the stringList from model import
bool emissionFuncParam::parse(stringList& lst, tracks& trcks, weights* wts, StateFuncs* funcs) {

    size_t idx;

    //FUNCTION NAME (REQUIRED)
    if (lst.contains("FUNCTION")) {
        idx=lst.indexOf("FUNCTION");
        idx++;
        emissionFuncName = lst[idx];
        if (funcs!=NULL) {
            emissionFunction = funcs->getEmissionFunction(emissionFuncName);
        }
    }
    else {
        std::cerr << "Tag was parsed but contains no FUNCTION: . Please check the formatting of the tags\n" << std::endl;
        return false;

        //errorInfo(sCantParseLine, "Tag was parsed but contains no FUNCTION: . Please check the formatting of the tags\n");
    }

    //Implement Which track to pass to function

    if (lst.contains("TRACK")) {
        idx=lst.indexOf("TRACK");
        idx++;
        trackName=lst[idx];
        emissionFuncTrack = trcks.getTrack(trackName);
        trackNumber = emissionFuncTrack->getIndex();
    }
    else {
        std::cerr << "Tag was parsed but contains no TRACK: . Please check the formatting of the tags\n" << std::endl;
        return false;

        //errorInfo(sCantParseLine, "Tag was parsed but contains no TRACK: . Please check the formatting of the tags\n");
    }



    if (lst.contains("SCALE")) {
        idx=lst.indexOf("SCALE");
        idx++;
        if (isNumeric(lst[idx])) {
            emissionFuncScaling = new(std::nothrow) weight;

            if (emissionFuncScaling==NULL) {
                std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
                exit(1);
            }

            double tempValue;
            if (!stringToDouble(lst[idx], tempValue)) {
                std::cerr << "SCALE value could not be converted to numerical value: "<< lst[idx] << std::endl;
                return false;
            }

            emissionFuncScaling->setAbsolute(tempValue);
        }
        else {
            std::string weightName=lst[idx];
            if (wts->count(weightName)) {
                emissionFuncScaling = (*wts)[weightName];
            }
        }

    }

    return true;
}
コード例 #12
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;
}
コード例 #13
0
//指定文字列が文字列リストに存在するかどうかどうかのチェック
bool SNetList::quaryExist(stringList& strlist,string& str)
{
	if(strlist.end() != find(strlist.begin(),strlist.end(),str)) return true;
	else return false;
}