예제 #1
0
void readConfig( istringstream& iss,
                 int& n_in,
                 int& n_out,
                 int& n_vocab,
                 int& n_project,
                 int& n_order,
                 float& momentum,
                 float& weight_decay,
                 float& alpha,
                 float& lnZ, 
                 string& norm_type, 
                 float& norm_param ) {
    n_in = 0;
    n_out = 0;
    n_vocab = 0;
    n_project = 0;
    n_order = 0;
    momentum = 0.0f;
    weight_decay = 0.0f;
    alpha = 0.0f;
    lnZ = 0.0f;
    norm_type = "none";
    norm_param = 10.0f;

    string token;
    while ( !iss.eof() ) {
        iss >> token;
        if ( token == "vocabulary" ) {
            iss >> n_vocab;
        }
        else if ( token == "projection" ) {
예제 #2
0
void TandemNativeParser::getPeaks(
  istringstream& tokenizer, ///< string version of values
  float* array,            ///< store values here
  int maxSize)              ///< array size
{
    // store values
    int curIdx = 0;
    while( !tokenizer.eof() ){
        assert(curIdx < maxSize);
        tokenizer >> array[curIdx];
        curIdx++;
    }
}
예제 #3
0
bool OBJFile::ReadFace(istringstream& line){
    Face face;
    string vertex;

    while(!line.eof()){
        line >> vertex;
            vector<string> index;
            Split(vertex, index, "/");
            size_t current = strtoul(index[0].c_str(), NULL, 10)-1;
            face.Vertex.push_back(current);
    }
    m_faces.push_back(face);
    return true;

}
예제 #4
0
int loadBodyFromModelLoader(::World* world, const char* name, const char *URL, istringstream &strm)
{
    vector<string> argvec;
    while (!strm.eof()){
        string arg;
        strm >> arg;
        argvec.push_back(arg);
    }
    int argc = argvec.size();
    char **argv = new char *[argc];
    for (int i=0; i<argc; i++){
        argv[i] = (char *)argvec[i].c_str();
    }

	int ret = loadBodyFromModelLoader(world, name, URL, argc, argv);

    delete [] argv;

    return ret;
}
예제 #5
0
파일: sequence.cpp 프로젝트: jklynch/mothur
//********************************************************************************************************************
//this function will jump over commented out sequences, but if the last sequence in a file is commented out it makes a blank seq
Sequence::Sequence(istringstream& fastaString){
	try {
		m = MothurOut::getInstance();
	
		initialize();
        name = getSequenceName(fastaString);
		
		if (!m->control_pressed) { 
			string sequence;
		
			//read comments
			while ((name[0] == '#') && fastaString) { 
				while (!fastaString.eof())	{	char c = fastaString.get(); if (c == 10 || c == 13){	break;	}	} // get rest of line if there's any crap there
				sequence = getCommentString(fastaString);
				
				if (fastaString) {  
					fastaString >> name;  
					name = name.substr(1);	
				}else { 
					name = "";
					break;
				}
			}
			
			//while (!fastaString.eof())	{	char c = fastaString.get();  if (c == 10 || c == 13){ break;	}	} // get rest of line if there's any crap there
            comment = getCommentString(fastaString);
			
			int numAmbig = 0;
			sequence = getSequenceString(fastaString, numAmbig);
			
			setAligned(sequence);	
			//setUnaligned removes any gap characters for us						
			setUnaligned(sequence);	
			
			if ((numAmbig / (float) numBases) > 0.25) { m->mothurOut("[WARNING]: We found more than 25% of the bases in sequence " + name + " to be ambiguous. Mothur is not setup to process protein sequences."); m->mothurOutEndLine(); }
		}
예제 #6
0
}

/** Load k-mer with coverage data.
 * @return the number of k-mer loaded
 */
static size_t loadKmer(ISequenceCollection& g, FastaReader& in)
{
	assert(opt::rank == -1);
	size_t count = 0;
	for (FastaRecord rec; in >> rec;) {
		assert(rec.seq.size() == opt::kmerSize);
		istringstream iss(rec.id);
		float coverage = 1;
		iss >> coverage;
		assert(iss);
		assert(iss.eof());
		g.add(Kmer(rec.seq), max(1, (int)ceilf(coverage)));

		if (++count % 1000000 == 0) {
			logger(1) << "Read " << count << " k-mer. ";
			g.printLoad();
		}
		g.pumpNetwork();
	}
	assert(in.eof());
	return count;
}

/** Load sequence data into the collection. */
void loadSequences(ISequenceCollection* seqCollection, string inFile)
{