src/fasta.cpp
// reading the weight vector from a fasta like plain file
// since both the writing and the reading of weight vector file is vary slow, we are not using it at this moment
reading the weight vector from a fasta like plain file
since both the writing and the reading of weight vector file is vary slow, we are not using it at this moment
reading the weight vector from a fasta like plain file since both the writing and the reading of weight vector file is vary slow we are not using it at this moment
void charByCharCategoryRead( const std::string& filePath, std::map<std::string, std::string> & seqs, std::map<std::string, int16_t * > & weight ) {
    for( std::map<std::string, std::string>::iterator it = seqs.begin(); it!=seqs.end(); ++it ){
        weight[it->first] = new int16_t[it->second.size()];
    }
    std::ifstream infile(filePath);
    if( ! infile.good()){
        std::cerr << "error in opening fasta file " << filePath << std::endl;
        exit (1);
    }
    std::string name="";
    std::string line;
    int16_t thisCategory;
    int32_t thisId;
    while (std::getline(infile, line)){
        if( line[0] == '>'  ){
            name=line.substr(1, line.find(" ", 0)-1);
            if( name[0] == '>' ){
                name=name.substr(1, name.find("\t", 0)-1);
            }else{
                name=name.substr(0, name.find("\t", 0)-1);
            }
            thisId=0;
        }else{
            std::stringstream ss(line);
            std::string item;
            while (std::getline(ss, item, '\t')) {
                if (item.length() > 0) {
                    weight[name][thisId] = std::stoi(item);
                    ++thisId;
                }
            }
        }
    }
}
void charByCharCategoryRead ( const std :: string & filePath , std :: map < std :: string , std :: string > & seqs , std :: map < std :: string , int16_t * > & weight ) { for ( std :: map < std :: string , std :: string > :: iterator it = seqs . begin ( ) ; it != seqs . end ( ) ; ++ it ) { weight [ it -> first ] = new int16_t [ it -> second . size ( ) ] ; } std :: ifstream infile ( filePath ) ; if ( ! infile . good ( ) ) { std :: cerr << " " << filePath << std :: endl ; exit ( 1 ) ; } std :: string name = " " ; std :: string line ; int16_t thisCategory ; int32_t thisId ; while ( std :: getline ( infile , line ) ) { if ( line [ 0 ] == ' ' ) { name = line . substr ( 1 , line . find ( " " , 0 ) - 1 ) ; if ( name [ 0 ] == ' ' ) { name = name . substr ( 1 , name . find ( " \t " , 0 ) - 1 ) ; } else { name = name . substr ( 0 , name . find ( " \t " , 0 ) - 1 ) ; } thisId = 0 ; } else { std :: stringstream ss ( line ) ; std :: string item ; while ( std :: getline ( ss , item , ' \t ' ) ) { if ( item . length ( ) > 0 ) { weight [ name ] [ thisId ] = std :: stoi ( item ) ; ++ thisId ; } } } } }
reading the weight vector from a fasta like plain file
since both the writing and the reading of weight vector file is vary slow, we are not using it at this moment
reading the weight vector from a fasta like plain file since both the writing and the reading of weight vector file is vary slow we are not using it at this moment