StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes
StochHMM::seqTracks Class Reference

#include <seqTracks.h>

List of all members.

Public Member Functions

 seqTracks ()
 Create an empty initialized seqTrack.
 seqTracks (model &, std::string &)
 seqTracks (model &, std::string &, SeqFileFormat)
 seqTracks (model &, std::string &, SeqFileFormat, TrackFuncs *)
 seqTracks (model &, std::vector< std::string > &, SeqFileFormat, SeqFilesType)
 seqTracks (model &, std::vector< std::string > &, SeqFileFormat, SeqFilesType, TrackFuncs *)
 seqTracks (models &, std::string &, SeqFileFormat, pt2Attrib *)
 seqTracks (models &, std::string &, SeqFileFormat, pt2Attrib *, TrackFuncs *)
 seqTracks (models &, std::vector< std::string > &, SeqFileFormat, SeqFilesType, pt2Attrib *)
 seqTracks (models &, std::vector< std::string > &, SeqFileFormat, SeqFilesType, pt2Attrib *, TrackFuncs *)
 ~seqTracks ()
 Destroy seqTracks.
bool loadSeqs (model &, std::string &)
bool loadSeqs (model &, std::string &, SeqFileFormat)
bool loadSeqs (model &, std::string &, SeqFileFormat, TrackFuncs *)
bool loadSeqs (model &, std::vector< std::string > &, SeqFileFormat, SeqFilesType)
bool loadSeqs (model &, std::vector< std::string > &, SeqFileFormat, SeqFilesType, TrackFuncs *)
bool loadSeqs (models &, std::string &, SeqFileFormat, pt2Attrib *, TrackFuncs *)
bool loadSeqs (models &, std::string &, SeqFileFormat)
bool loadSeqs (models &, std::vector< std::string > &, SeqFileFormat, SeqFilesType, pt2Attrib *, TrackFuncs *)
bool loadSeqs (models &, std::vector< std::string > &, SeqFileFormat, SeqFilesType)
bool loadSeqs (models &, std::vector< std::string > &, SeqFileFormat, SeqFilesType, pt2Attrib *)
void setAttribFunc (pt2Attrib *func)
 Sets the function to evaluate the which model to use with a particular sequence.
void setTrackFunc (TrackFuncs *func)
 Sets a trackfunction that will be evaluated to generate a necessary track for the model.
void setNumImportJobs (size_t value)
void setTrackFilename (std::string &, std::string &)
bool getNext ()
 Get the next sequence job.
bool importJobs ()
 Get a job and Add to the queue.
seqJobgetJob ()
sequencegetFasta (int)
sequencegetFastq (int)
sequencegetReal (int)
size_t size (void)
size_t getTrackCount ()
void print ()
 Print the seqTracks to stdout.
void getInformation ()
float remainingSeqs ()

Private Member Functions

ExDefSequencegetExDef (int, int)
bool _loadFASTA (std::string &, SeqFilesType)
bool _loadFASTA (std::vector< std::string > &, SeqFilesType)
bool _loadFASTQ (std::string &, SeqFilesType)
bool _loadFASTQ (std::vector< std::string > &, SeqFilesType)
bool _initImportTrackInfo (void)
void _reset ()
void _init ()
bool _open ()
bool _close ()

Private Attributes

std::vector< std::ifstream * > filehandles
std::vector< std::string > seqFilenames
size_t numImportJobs
bool good
TrackFuncstrackFunctions
pt2AttribattribModelFunc
int TrackToUseForAttrib
stateInfoinfo
std::vector< std::pair< int,
trackType > > 
importTracks
std::vector< ppTrackpostprocessTracks
modelshmms
modelhmm
tracksmodelTracks
SeqFileFormat seqFormat
SeqFilesType fileType
size_t trackCount
stringList input
std::queue< seqJob * > jobQueue
size_t jobs
int exit_thread

Detailed Description

Definition at line 90 of file seqTracks.h.


Constructor & Destructor Documentation

StochHMM::seqTracks::seqTracks ( )

Create an empty initialized seqTrack.

Definition at line 34 of file seqTracks.cpp.

References _init().

{
_init();
return;
}
StochHMM::seqTracks::seqTracks ( model mdl,
std::string &  filename 
)

Create, initialize, and start loading sequence file

Parameters:
mdlSingle model
filenameSequence File filename
formatSequence file Format (FASTA or FASTQ)

Definition at line 45 of file seqTracks.cpp.

References _init(), StochHMM::FASTA, and loadSeqs().

{
_init();
loadSeqs(mdl, filename, FASTA, NULL);
return;
}
StochHMM::seqTracks::seqTracks ( model mdl,
std::string &  filename,
SeqFileFormat  format 
)

Create, initialize, and start loading sequence file

Parameters:
mdlSingle model
filenameSequence File filename
formatSequence file Format (FASTA or FASTQ)

Definition at line 58 of file seqTracks.cpp.

References _init(), and loadSeqs().

{
_init();
loadSeqs(mdl, filename, format, NULL);
return;
}
StochHMM::seqTracks::seqTracks ( model mdl,
std::string &  filename,
SeqFileFormat  format,
TrackFuncs trFunc 
)

Create, initialize, and start loading sequence file

Parameters:
mdlSingle model
filenameSequence File filename
formatSequence file Format (FASTA or FASTQ)
trFuncTrackFunc* functions to create tracks based on imported sequences

Definition at line 71 of file seqTracks.cpp.

References _init(), and loadSeqs().

{
_init();
loadSeqs(mdl, filename,format, trFunc);
return;
}
StochHMM::seqTracks::seqTracks ( model mdl,
std::vector< std::string > &  filenames,
SeqFileFormat  format,
SeqFilesType  type 
)

Create, initialize, and start loading sequence file

Parameters:
mdlSingle model
filenamesList of Sequence File filenames
formatSequence file Format (FASTA or FASTQ)
typeSingle track per file (SINGLE) or multiple tracks per file (MULTI)

Definition at line 88 of file seqTracks.cpp.

References _init(), and loadSeqs().

{
_init();
loadSeqs(mdl, filenames, format, type, NULL);
return;
}
StochHMM::seqTracks::seqTracks ( model mdl,
std::vector< std::string > &  filenames,
SeqFileFormat  format,
SeqFilesType  type,
TrackFuncs trFunc 
)

Create, initialize, and start loading sequence file

Parameters:
mdlSingle Model
filenamesList of Sequence File filenames
formatSequence file Format (FASTA or FASTQ)
typeSingle track per file (SINGLE) or multiple tracks per file (MULTI)
trFuncTrackFunc* functions to create tracks based on imported sequences

Definition at line 103 of file seqTracks.cpp.

References _init(), and loadSeqs().

{
_init();
loadSeqs(mdl, filenames, format, type, trFunc);
return;
}
StochHMM::seqTracks::seqTracks ( models mdls,
std::string &  filename,
SeqFileFormat  format,
pt2Attrib attribFunc 
)

Create, initialize, and start loading sequence file

Parameters:
mdlsMultiple models
filenameSequence File filename
formatSequence file Format (FASTA or FASTQ)
attribFuncpt2Attrib function to choose model based on sequence attributes

Definition at line 121 of file seqTracks.cpp.

References _init(), and loadSeqs().

{
_init();
loadSeqs(mdls,filename,format,attribFunc, NULL);
return;
}
StochHMM::seqTracks::seqTracks ( models mdls,
std::string &  filename,
SeqFileFormat  format,
pt2Attrib attribFunc,
TrackFuncs trFunc 
)

Create, initialize, and start loading sequence file

Parameters:
mdlsMultiple models
filenameSequence File filename
formatSequence file Format (FASTA or FASTQ)
attribFuncpt2Attrib function to choose model based on sequence attributes
trFuncTrackFunc* functions to create tracks based on imported sequences

Definition at line 136 of file seqTracks.cpp.

References _init(), and loadSeqs().

{
_init();
loadSeqs(mdls,filename,format,attribFunc,trFunc);
return;
}
StochHMM::seqTracks::seqTracks ( models mdls,
std::vector< std::string > &  filenames,
SeqFileFormat  format,
SeqFilesType  type,
pt2Attrib attribFunc 
)

Create, initialize, and start loading sequence file

Parameters:
mdlsMultiple models
filenamesList of Sequence File filenames
formatSequence file Format (FASTA or FASTQ)
typeSingle track per file (SINGLE) or multiple tracks per file (MULTI)
attribFuncpt2Attrib function to choose model based on sequence attributes

Definition at line 153 of file seqTracks.cpp.

References _init(), and loadSeqs().

{
_init();
loadSeqs(mdls, filenames, format, type, attribFunc, NULL);
return;
}
StochHMM::seqTracks::seqTracks ( models mdls,
std::vector< std::string > &  filenames,
SeqFileFormat  format,
SeqFilesType  type,
pt2Attrib attribFunc,
TrackFuncs trFunc 
)

Create, initialize, and start loading sequence file

Parameters:
mdlsMultiple models
filenamesList of Sequence File filenames
formatSequence file Format (FASTA or FASTQ)
typeSingle track per file (SINGLE) or multiple tracks per file (MULTI)
attribFuncpt2Attrib function to choose model based on sequence attributes
trFuncTrackFunc* functions to create tracks based on imported sequences

Definition at line 169 of file seqTracks.cpp.

References _init(), and loadSeqs().

{
_init();
loadSeqs(mdls, filenames, format, type, attribFunc, trFunc);
return;
}
StochHMM::seqTracks::~seqTracks ( )

Destroy seqTracks.

Definition at line 180 of file seqTracks.cpp.

References attribModelFunc, filehandles, hmms, jobQueue, and trackFunctions.

{
for(size_t i=0;i<filehandles.size();i++){
if (filehandles[i]!=NULL){
filehandles[i]->close();
}
}
hmms=NULL;
while(!jobQueue.empty()){
seqJob* element=jobQueue.front();
jobQueue.pop();
delete element;
element = NULL;
}
return;
}

Member Function Documentation

bool StochHMM::seqTracks::_close ( )
private

Definition at line 971 of file seqTracks.cpp.

References filehandles, fileType, importTracks, seqFilenames, and StochHMM::SINGLE_TRACK.

Referenced by getJob(), and importJobs().

{
for(size_t i=0;i<importTracks.size();i++){
//std::cout << importTracks.size() << "\t" << filehandles.size() << std::endl;
if (filehandles.size()>=importTracks.size()){
filehandles[i]->close();
delete filehandles[i];
filehandles[i]=NULL;
filehandles.erase(filehandles.begin());
seqFilenames.erase(seqFilenames.begin());
}
}
}
else{
filehandles[0]->clear();
delete filehandles[0];
filehandles.erase(filehandles.begin());
seqFilenames.erase(seqFilenames.begin());
}
return true;
}
void StochHMM::seqTracks::_init ( )
private

Definition at line 202 of file seqTracks.cpp.

References attribModelFunc, exit_thread, StochHMM::FASTA, fileType, good, hmm, hmms, jobs, numImportJobs, seqFormat, StochHMM::SINGLE_TRACK, and trackFunctions.

Referenced by seqTracks().

{
jobs=0;
hmms = NULL;
hmm = NULL;
seqFormat = FASTA; //Set default file format to fasta
good=false;
//Make seqTrack thread-safe
#ifdef THREADS
pthread_mutex_init(&exit_thread_flag_mutex, NULL);
pthread_cond_init(&exit_thread_flag_cv, NULL);
#endif
}
bool StochHMM::seqTracks::_initImportTrackInfo ( void  )
private

Definition at line 622 of file seqTracks.cpp.

References StochHMM::ppTrack::func, StochHMM::track::getAlphaType(), StochHMM::model::getTrack(), StochHMM::track::getTrackFunction(), StochHMM::model::getTrackIter(), StochHMM::model::getTracks(), StochHMM::track::getTrackToUse(), hmm, hmms, importTracks, StochHMM::track::isTrackFuncDefined(), modelTracks, postprocessTracks, StochHMM::model::track_size(), trackCount, StochHMM::ppTrack::trackNumber, and StochHMM::ppTrack::trackToUse.

Referenced by loadSeqs().

{
model* temp = NULL;
if (hmms!=NULL){
temp = (*hmms)[0];
if (temp == NULL){
std::cerr << "seqTracks initialization error: Model not defined at index zero of models datatype. Can't initialize seqTrack with necessary model information" << std::endl;
return false;
}
}
else if (hmm!=NULL){
temp = hmm;
}
else{
std::cerr << "seqTracks initialization error: Model is not defined. Therefore, can't initiate seqTrack with necessary model inforamation" << std::endl;
return false;
}
modelTracks = temp->getTracks();
//Determine which tracks to import and which to get by using track functions
track* tempTrack;
trackCount= temp->track_size();
for(size_t i=0;i<trackCount;i++){
tempTrack = temp->getTrack(i);
if (tempTrack->isTrackFuncDefined()){
ppTrack tmp;
tmp.func = NULL;
tmp.trackNumber=i;
tmp.trackToUse=temp->getTrackIter(tempTrack->getTrackToUse());
std::string functionTouse=tempTrack->getTrackFunction();
//tmp.func = funcs->getFunction(functionTouse);
postprocessTracks.push_back(tmp);
}
else{
importTracks.push_back(std::make_pair(i,tempTrack->getAlphaType()));
}
}
return true;
}
bool StochHMM::seqTracks::_loadFASTA ( std::string &  ,
SeqFilesType   
)
private
bool StochHMM::seqTracks::_loadFASTA ( std::vector< std::string > &  ,
SeqFilesType   
)
private
bool StochHMM::seqTracks::_loadFASTQ ( std::string &  ,
SeqFilesType   
)
private
bool StochHMM::seqTracks::_loadFASTQ ( std::vector< std::string > &  ,
SeqFilesType   
)
private
bool StochHMM::seqTracks::_open ( )
private

Definition at line 890 of file seqTracks.cpp.

References filehandles, fileType, good, importTracks, seqFilenames, and StochHMM::SINGLE_TRACK.

Referenced by getJob(), importJobs(), and loadSeqs().

{
if (seqFilenames.size()==0){
return false;
}
if (seqFilenames.size()<importTracks.size()){
std::cerr << "Number of sequences provided doesn't match the number of tracks. Given that the sequences files contain a single track per file. " << std::endl;
}
for(size_t i = 0; i<importTracks.size();i++){
std::ifstream *SEQ= new(std::nothrow) std::ifstream;
if (SEQ==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
filehandles.push_back(SEQ);
if (seqFilenames.size()<i+1){
return false;
}
filehandles[i]->open(seqFilenames[i].c_str());
if (!filehandles[i]->is_open()){
std::cerr << "Can't open sequence file: " << seqFilenames[i] << std::endl;
return false;
}
if (filehandles[i]->good()){
good = true;
}
else{
std::cerr << "Can't read from file: " << seqFilenames[i] << std::endl;
if (fileType == SINGLE_TRACK && importTracks.size()>1){
std::cerr << "Failed import of " << seqFilenames[i] << " causes there to be a missing track in sequence data." << std::endl;
return false;
}
else{
std::cerr << "Skipped processing of " << seqFilenames[i] << "." << std::endl;
}
}
}
}
else {
std::ifstream *SEQ= new(std::nothrow) std::ifstream;
if (SEQ==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
filehandles.push_back(SEQ);
filehandles[0]->open(seqFilenames[0].c_str());
if (!filehandles[0]->is_open()){
std::cerr << "Can't open sequence file: " << seqFilenames[0] << std::endl;
return false;
}
if (filehandles[0]->good()){
good = true;
}
else{
std::cerr << "Can't read from file: " << seqFilenames[0] << std::endl;
return false;
}
}
return true;
}
void StochHMM::seqTracks::_reset ( )
private

Definition at line 227 of file seqTracks.cpp.

References exit_thread, StochHMM::FASTA, filehandles, fileType, good, hmm, hmms, importTracks, seqFilenames, seqFormat, and StochHMM::SINGLE_TRACK.

Referenced by loadSeqs().

{
for(size_t i=0;i<filehandles.size();i++){
delete filehandles[i];
}
filehandles.clear();
seqFilenames.clear();
hmms = NULL;
hmm = NULL;
good = false;
importTracks.clear();
}
ExDefSequence* StochHMM::seqTracks::getExDef ( int  ,
int   
)
private
sequence* StochHMM::seqTracks::getFasta ( int  )
sequence* StochHMM::seqTracks::getFastq ( int  )
void StochHMM::seqTracks::getInformation ( )
seqJob * StochHMM::seqTracks::getJob ( )

Get the next sequence(s) and model from the job queue *If the number of jobs falls below MIN_JOBS/2 then refill the queue *Else give pointer to the next job in the queue

Definition at line 577 of file seqTracks.cpp.

References _close(), _open(), fileType, getNext(), good, importTracks, jobQueue, jobs, numImportJobs, seqFilenames, and StochHMM::SINGLE_TRACK.

Referenced by main().

{
seqJob *jb= NULL;
//Check job queue and if necessary fill the job queue
if ((jobs==0 || (jobs < (numImportJobs/2))) && good){
while(good && jobs<numImportJobs){
}
}
if (!good){
if (seqFilenames.size()>importTracks.size()){
_close();
_open();
}
else{
_close();
}
}
else {
if (seqFilenames.size()>0){
_close();
_open();
}
else{
_close();
}
}
}
if (jobs>0){
jb=jobQueue.front();
jobQueue.pop();
jobs--;
}
return jb;
}
bool StochHMM::seqTracks::getNext ( )

Get the next sequence job.

Definition at line 696 of file seqTracks.cpp.

References StochHMM::sequences::addSeq(), attribModelFunc, StochHMM::sequence::exDefDefined(), StochHMM::FASTA, filehandles, fileType, StochHMM::model::getDistanceToAttrib(), StochHMM::sequence::getExDef(), StochHMM::sequence::getFasta(), StochHMM::sequence::getFastq(), StochHMM::sequences::getLength(), StochHMM::sequence::getReal(), StochHMM::sequences::getUndigitized(), good, hmm, StochHMM::seqJob::hmm, hmms, importTracks, info, jobQueue, jobs, StochHMM::min(), modelTracks, postprocessTracks, StochHMM::REAL, seqFilenames, seqFormat, StochHMM::seqJob::set, StochHMM::sequences::setExDef(), StochHMM::sequences::setLength(), StochHMM::seqJob::setSeqFilename(), StochHMM::SINGLE_TRACK, StochHMM::models::size(), SIZE_MAX, trackCount, and TrackToUseForAttrib.

Referenced by getJob(), and importJobs().

{
seqJob* temp_job=new(std::nothrow) seqJob(trackCount);
if (temp_job==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
bool valid=true;
sequence* sq;
//std::cout << importTracks.size() << std::endl;
for(size_t i=0;i<importTracks.size();i++){
bool success;
if (importTracks[i].second == REAL){
sq=new(std::nothrow) sequence(true);
if (sq==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
success = sq->getReal(*filehandles[i], (*modelTracks)[importTracks[i].first]);
}
else{
success = sq->getReal(*filehandles[0], (*modelTracks)[importTracks[i].first]);
}
}
else if (seqFormat == FASTA){ // AlphaNum and Fasta
sq=new(std::nothrow) sequence(false);
if (sq==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
success = sq->getFasta(*filehandles[i], (*modelTracks)[importTracks[i].first], info);
}
else{
success = sq->getFasta(*filehandles[0], (*modelTracks)[importTracks[i].first], info);
}
}
else{
sq=new(std::nothrow) sequence(false);
if (sq==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
success = sq->getFastq(*filehandles[i], (*modelTracks)[importTracks[i].first]);
}
else{
success = sq->getFastq(*filehandles[0], (*modelTracks)[importTracks[i].first]);
}
}
if (!filehandles[i]->good()){
good=false;
}
}
else{
if (!filehandles[0]->good()){
good=false;
}
}
if (!success){
std::cerr << "Failed to import data track from " << seqFilenames[i] << std::endl;
delete sq;
sq = NULL;
}
if (sq==NULL){ // If sequence is bad break
valid=false;
break;
}
else{
//If exDef is defined in sequence put it in sequences
if (sq->exDefDefined()){
temp_job->set->setExDef(sq->getExDef());
}
temp_job->set->addSeq(sq,importTracks[i].first);
temp_job->setSeqFilename(seqFilenames[i]);
}
else{
temp_job->setSeqFilename(seqFilenames[0]);
}
}
}
if (valid){
//Get sequences defined by sequence external function that is user-defined
for (size_t i =0;i<postprocessTracks.size();i++) {
std::vector<double>* rl = NULL;
if (postprocessTracks[i].func != NULL ){
rl = (*postprocessTracks[i].func)(temp_job->set->getUndigitized(postprocessTracks[i].trackToUse));
}
else{
std::cerr << "Sequence external function not defined for track number: " << postprocessTracks[i].trackNumber << std::endl;
std::cerr << "Using Sequences from track: " << postprocessTracks[i].trackToUse << std::endl;
rl = new(std::nothrow) std::vector<double>;
if (rl==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
}
sequence* sq = new(std::nothrow) sequence(rl , (*modelTracks)[postprocessTracks[i].trackNumber]);
if (sq==NULL){
std::cerr << "OUT OF MEMORY\nFile" << __FILE__ << "Line:\t"<< __LINE__ << std::endl;
exit(1);
}
temp_job->set->addSeq(sq,postprocessTracks[i].trackNumber);
}
//TODO: Fix the selection of models based upon the attribute model function
//Select Model based on models distance from attributes
if (hmms){
//If we have a attribute calculation function we'll access which model to use
//Calculate attribute
double attb = (*attribModelFunc)(temp_job->set->getUndigitized(TrackToUseForAttrib));
//assign first by default
double min = (*hmms)[0]->getDistanceToAttrib(attb);
temp_job->hmm=(*hmms)[0];
//Check other models for one that is closer to attb
for(size_t i=1;i<hmms->size();i++){
double newVal=(*hmms)[i]->getDistanceToAttrib(attb);
//If it's closer assign it to the job
if (newVal<min){
temp_job->hmm=(*hmms)[i];
}
}
}
else{
temp_job->hmm=(*hmms)[0]; //Default to first HMM
}
}
else{
temp_job->hmm=hmm; //assign single model to job
}
//Check that all sequences are same length.
size_t lengthOfAll=SIZE_MAX;
for (size_t i=0;i<trackCount;i++){
size_t length=temp_job->set->getLength(i);
if (lengthOfAll==SIZE_MAX){
lengthOfAll=length;
}
else if (lengthOfAll!=length){
std::cerr << "Sequence Lengths not the same" <<std::endl;
delete temp_job;
return false;
}
else {
continue;
}
}
temp_job->set->setLength(lengthOfAll);
jobQueue.push(temp_job);
jobs++;
}
else{
delete temp_job;
}
return true;
}
sequence* StochHMM::seqTracks::getReal ( int  )
size_t StochHMM::seqTracks::getTrackCount ( )
inline

Definition at line 169 of file seqTracks.h.

References trackCount.

{return trackCount;}
bool StochHMM::seqTracks::importJobs ( )

Get a job and Add to the queue.

Definition at line 677 of file seqTracks.cpp.

References _close(), _open(), getNext(), good, importTracks, jobs, numImportJobs, and seqFilenames.

Referenced by loadSeqs().

{
while(good && jobs<numImportJobs){
}
if (!good && seqFilenames.size()>importTracks.size()){
_close();
_open();
}
return true;
}
bool StochHMM::seqTracks::loadSeqs ( model mod,
std::string &  seqFile 
)

Load the fasta sequence file

Parameters:
modModel to be used
seqFileFasta sequence filename

Definition at line 261 of file seqTracks.cpp.

References StochHMM::FASTA.

Referenced by import_sequence(), loadSeqs(), and seqTracks().

{
return loadSeqs(mod,seqFile,FASTA,NULL);
}
bool StochHMM::seqTracks::loadSeqs ( model mod,
std::string &  seqFile,
SeqFileFormat  format 
)

Load the fasta sequence file

Parameters:
modModel to be used
seqFileFasta sequence filename

Definition at line 269 of file seqTracks.cpp.

References loadSeqs().

{
return loadSeqs(mod,seqFile,format,NULL);
}
bool StochHMM::seqTracks::loadSeqs ( model mod,
std::string &  seqFile,
SeqFileFormat  format,
TrackFuncs trFuncs 
)

Load the fasta sequence file

Parameters:
modModel to be used
seqFileSequence filename

Definition at line 277 of file seqTracks.cpp.

References _initImportTrackInfo(), _open(), _reset(), filehandles, fileType, StochHMM::model::getStateInfo(), hmm, importJobs(), importTracks, info, StochHMM::MULTI_TRACK, seqFilenames, seqFormat, StochHMM::SINGLE_TRACK, and trackFunctions.

{
if (filehandles.size()>0){
_reset();
}
hmm = &mod;
seqFormat = format;
seqFilenames.push_back(seqFile);
//Assign valid Track Functions
if (trFuncs!=NULL){
trackFunctions = trFuncs;
}
//Get State Information and Determine # of tracks to import
info = mod.getStateInfo();
_open();
//Fill Job Queue
return true;
}
bool StochHMM::seqTracks::loadSeqs ( model mod,
std::vector< std::string > &  seqFiles,
SeqFileFormat  format,
SeqFilesType  type 
)

Load the fasta sequence files

Parameters:
modModel to be used
seqFileFasta sequence filenames
typeSINGLE track per file or MULTI tracks per file

Definition at line 315 of file seqTracks.cpp.

References loadSeqs().

{
return loadSeqs(mod, seqFiles, format,type,NULL);
}
bool StochHMM::seqTracks::loadSeqs ( model mod,
std::vector< std::string > &  seqFiles,
SeqFileFormat  format,
SeqFilesType  type,
TrackFuncs trFuncs 
)

Load the fasta sequence files

Parameters:
modModel to be used
seqFileFasta sequence filenames
typeSINGLE track per file or MULTI tracks per file
trFuncsTrack Functions to create tracks using imported seqs

Definition at line 325 of file seqTracks.cpp.

References _initImportTrackInfo(), _open(), _reset(), filehandles, fileType, StochHMM::model::getStateInfo(), hmm, importJobs(), importTracks, info, seqFilenames, seqFormat, StochHMM::SINGLE_TRACK, and trackFunctions.

{
if (filehandles.size()>0 || importTracks.size()>0){
_reset();
}
hmm = &mod;
seqFormat = format;
fileType = type;
seqFilenames = seqFiles;
//Assign valid Track Functions
if (trFuncs!=NULL){
trackFunctions = trFuncs;
}
//Get State Information and Determine # of tracks to import
info = mod.getStateInfo();
size_t tracksToImport = importTracks.size();
if (fileType == SINGLE_TRACK && tracksToImport>1){
size_t sequenceFiles = seqFiles.size();
if (tracksToImport!=sequenceFiles){
std::cerr << "Number of tracks to import and sequenced don't match. # Files == # Tracks to import " << std::endl;
_reset();
return false;
}
}
//Open File
_open();
// for(size_t i = 0; i<seqFiles.size();i++){
// std::ifstream *SEQ= new std::ifstream;
// filehandles.push_back(SEQ);
//
// filehandles[i]->open(seqFiles[i].c_str());
//
// if (!filehandles[i]->is_open()){
// std::cerr << "Can't open sequence file: " << seqFiles[i] << std::endl;
// return false;
// }
//
// if (filehandles[i]->good()){
// good = true;
// }
// else{
// std::cerr << "Can't read from file: " << seqFiles[i] << std::endl;
//
// if (fileType == SINGLE_TRACK && importTracks.size()>1){
// std::cerr << "Failed import of " << seqFiles[i] << " causes there to be a missing track in sequence data." << std::endl;
// return false;
// }
// else{
// std::cerr << "Skipped processing of " << seqFiles[i] << "." << std::endl;
// }
// }
// }
//Fill Job Queue
return true;
}
bool StochHMM::seqTracks::loadSeqs ( models mModels,
std::string &  seqFile,
SeqFileFormat  format,
pt2Attrib attribFunc,
TrackFuncs trFuncs 
)

Load the fasta sequence file

Parameters:
mModelsModels to be used
seqFileSequence filename
formatSequence File Format
attribFuncPointer to Attribute calculation function
trFuncsPointer to Track Functions

Definition at line 405 of file seqTracks.cpp.

References _initImportTrackInfo(), _open(), _reset(), attribModelFunc, filehandles, fileType, StochHMM::models::getModel(), StochHMM::model::getStateInfo(), hmms, importJobs(), importTracks, info, StochHMM::MULTI_TRACK, seqFilenames, seqFormat, StochHMM::SINGLE_TRACK, and trackFunctions.

{
if (filehandles.size()>0){
_reset();
}
hmms = &mModels;
seqFormat = format;
seqFilenames.push_back(seqFile);
//Assign valid Attribute Function
if (attribFunc!=NULL){
attribModelFunc = attribFunc;
}
if (attribModelFunc==NULL){
std::cerr << "No valid Attribute calculating function" << std::endl;
return false;
}
//Assign valid Track Functions
if (trFuncs!=NULL){
trackFunctions = trFuncs;
}
//Get State Information and Determine # of tracks to import
//Open File
_open();
// std::ifstream *SEQ= new std::ifstream;
// filehandles.push_back(SEQ);
//
// filehandles[0]->open(seqFile.c_str());
//
// if (!filehandles[0]->is_open()){
// std::cerr << "Can't open sequence file: " << seqFile << std::endl;
// return false;
// }
//
// if (filehandles[0]->good()){
// good = true;
// }
// else{
// std::cerr << "Can't read from file: " << seqFile << std::endl;
// return false;
// }
//Fill Job Queue
return true;
}
bool StochHMM::seqTracks::loadSeqs ( models mModels,
std::string &  seqFile,
SeqFileFormat  format 
)

Load the fasta sequence file

Parameters:
mModelsModels to be used
seqFileFasta sequence filename

Definition at line 467 of file seqTracks.cpp.

References loadSeqs().

{
return loadSeqs(mModels, seqFile, format, NULL,NULL);
}
bool StochHMM::seqTracks::loadSeqs ( models mModels,
std::vector< std::string > &  seqFiles,
SeqFileFormat  format,
SeqFilesType  type,
pt2Attrib attribFunc,
TrackFuncs trFuncs 
)

Load the fasta sequence files

Parameters:
mModelsModels to be used
seqFilesFasta sequence filenames

Definition at line 480 of file seqTracks.cpp.

References _initImportTrackInfo(), _open(), _reset(), attribModelFunc, filehandles, fileType, StochHMM::models::getModel(), StochHMM::model::getStateInfo(), hmms, importJobs(), importTracks, info, seqFilenames, seqFormat, StochHMM::SINGLE_TRACK, and trackFunctions.

{
if (filehandles.size()>0){
_reset();
}
hmms = &mModels;
seqFormat = format;
fileType = type;
seqFilenames = seqFiles;
//Assign valid Track Functions
if (trFuncs!=NULL){
trackFunctions = trFuncs;
}
//Assign valid Attribute Function
if (attribFunc!=NULL){
attribModelFunc = attribFunc;
}
if (attribModelFunc==NULL){
std::cerr << "No valid Attribute calculating function" << std::endl;
return false;
}
//Get State Information and Determine # of tracks to import
size_t tracksToImport = importTracks.size();
if (fileType == SINGLE_TRACK && tracksToImport>1){
size_t sequenceFiles = seqFiles.size();
if (tracksToImport!=sequenceFiles){
std::cerr << "Number of tracks to import and sequenced don't match. # Files == # Tracks to import " << std::endl;
return false;
}
}
//Open File
_open();
// for(size_t i = 0; i<seqFiles.size();i++){
// std::ifstream *SEQ= new std::ifstream;
// filehandles.push_back(SEQ);
//
// filehandles[i]->open(seqFiles[i].c_str());
//
// if (!filehandles[i]->is_open()){
// std::cerr << "Can't open sequence file: " << seqFiles[i] << std::endl;
// return false;
// }
//
// if (filehandles[i]->good()){
// good = true;
// }
// else{
// std::cerr << "Can't read from file: " << seqFiles[i] << std::endl;
//
// if (fileType == SINGLE_TRACK && importTracks.size()>1){
// std::cerr << "Failed import of " << seqFiles[i] << " causes there to be a missing track in sequence data." << std::endl;
// return false;
// }
// else{
// std::cerr << "Skipped processing of " << seqFiles[i] << "." << std::endl;
// }
// }
// }
//Fill Job Queue
return true;
}
bool StochHMM::seqTracks::loadSeqs ( models mModels,
std::vector< std::string > &  seqFiles,
SeqFileFormat  format,
SeqFilesType  type 
)

Load the fasta sequence files

Parameters:
mModelsModels to be used
seqFilesFasta sequence filenames

Definition at line 561 of file seqTracks.cpp.

References loadSeqs().

{
return loadSeqs(mModels, seqFiles, format, type, NULL, NULL);
}
bool StochHMM::seqTracks::loadSeqs ( models mModels,
std::vector< std::string > &  seqFiles,
SeqFileFormat  format,
SeqFilesType  type,
pt2Attrib attribFunc 
)

Load the fasta sequence files

Parameters:
mModelsModels to be used
seqFilesFasta sequence filenames

Definition at line 569 of file seqTracks.cpp.

References loadSeqs().

{
return loadSeqs(mModels, seqFiles, format, type,attribFunc,NULL);
}
void StochHMM::seqTracks::print ( )

Print the seqTracks to stdout.

Definition at line 667 of file seqTracks.cpp.

References jobQueue.

{
for (size_t i=0;i<jobQueue.size();i++){
//jobQueue[i]->print_seq();
}
return;
}
float StochHMM::seqTracks::remainingSeqs ( )
inline

Definition at line 173 of file seqTracks.h.

References importTracks, and seqFilenames.

{
float val = (float) seqFilenames.size() / (float) importTracks.size();
//std::cout << seqFilenames.size() <<"\t" << importTracks.size() <<"\t" << val << std::endl;
return val;}
void StochHMM::seqTracks::setAttribFunc ( pt2Attrib func)
inline

Sets the function to evaluate the which model to use with a particular sequence.

Definition at line 150 of file seqTracks.h.

References attribModelFunc.

void StochHMM::seqTracks::setNumImportJobs ( size_t  value)
inline

Definition at line 154 of file seqTracks.h.

References numImportJobs.

{numImportJobs=value;}
void StochHMM::seqTracks::setTrackFilename ( std::string &  ,
std::string &   
)
void StochHMM::seqTracks::setTrackFunc ( TrackFuncs func)
inline

Sets a trackfunction that will be evaluated to generate a necessary track for the model.

Definition at line 153 of file seqTracks.h.

References trackFunctions.

size_t StochHMM::seqTracks::size ( void  )
inline

Definition at line 168 of file seqTracks.h.

References jobQueue.

{return jobQueue.size();}

Member Data Documentation

pt2Attrib* StochHMM::seqTracks::attribModelFunc
private

Definition at line 186 of file seqTracks.h.

Referenced by _init(), getNext(), loadSeqs(), setAttribFunc(), and ~seqTracks().

int StochHMM::seqTracks::exit_thread
private

Definition at line 215 of file seqTracks.h.

Referenced by _init(), and _reset().

std::vector<std::ifstream*> StochHMM::seqTracks::filehandles
private

Definition at line 180 of file seqTracks.h.

Referenced by _close(), _open(), _reset(), getNext(), loadSeqs(), and ~seqTracks().

SeqFilesType StochHMM::seqTracks::fileType
private

Definition at line 202 of file seqTracks.h.

Referenced by _close(), _init(), _open(), _reset(), getJob(), getNext(), and loadSeqs().

bool StochHMM::seqTracks::good
private

Definition at line 183 of file seqTracks.h.

Referenced by _init(), _open(), _reset(), getJob(), getNext(), and importJobs().

model* StochHMM::seqTracks::hmm
private

Definition at line 198 of file seqTracks.h.

Referenced by _init(), _initImportTrackInfo(), _reset(), getNext(), and loadSeqs().

models* StochHMM::seqTracks::hmms
private

Definition at line 197 of file seqTracks.h.

Referenced by _init(), _initImportTrackInfo(), _reset(), getNext(), loadSeqs(), and ~seqTracks().

std::vector<std::pair<int,trackType> > StochHMM::seqTracks::importTracks
private
stateInfo* StochHMM::seqTracks::info
private

Definition at line 191 of file seqTracks.h.

Referenced by getNext(), and loadSeqs().

stringList StochHMM::seqTracks::input
private

Definition at line 209 of file seqTracks.h.

std::queue<seqJob*> StochHMM::seqTracks::jobQueue
private

Definition at line 213 of file seqTracks.h.

Referenced by getJob(), getNext(), print(), size(), and ~seqTracks().

size_t StochHMM::seqTracks::jobs
private

Definition at line 214 of file seqTracks.h.

Referenced by _init(), getJob(), getNext(), and importJobs().

tracks* StochHMM::seqTracks::modelTracks
private

Definition at line 199 of file seqTracks.h.

Referenced by _initImportTrackInfo(), and getNext().

size_t StochHMM::seqTracks::numImportJobs
private

Definition at line 182 of file seqTracks.h.

Referenced by _init(), getJob(), importJobs(), and setNumImportJobs().

std::vector<ppTrack> StochHMM::seqTracks::postprocessTracks
private

Definition at line 194 of file seqTracks.h.

Referenced by _initImportTrackInfo(), and getNext().

std::vector<std::string> StochHMM::seqTracks::seqFilenames
private

Definition at line 181 of file seqTracks.h.

Referenced by _close(), _open(), _reset(), getJob(), getNext(), importJobs(), loadSeqs(), and remainingSeqs().

SeqFileFormat StochHMM::seqTracks::seqFormat
private

Definition at line 201 of file seqTracks.h.

Referenced by _init(), _reset(), getNext(), and loadSeqs().

size_t StochHMM::seqTracks::trackCount
private

Definition at line 208 of file seqTracks.h.

Referenced by _initImportTrackInfo(), getNext(), and getTrackCount().

TrackFuncs* StochHMM::seqTracks::trackFunctions
private

Definition at line 185 of file seqTracks.h.

Referenced by _init(), loadSeqs(), setTrackFunc(), and ~seqTracks().

int StochHMM::seqTracks::TrackToUseForAttrib
private

Definition at line 189 of file seqTracks.h.

Referenced by getNext().


The documentation for this class was generated from the following files: