50 real=
new(std::nothrow) std::vector<double>;
53 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
61 seq=
new(std::nothrow) std::vector<uint8_t>;
64 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
96 seq =
new(std::nothrow) std::vector<uint8_t>;
99 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
120 seq =
new(std::nothrow) std::vector<uint8_t>;
123 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
164 seq =
new(std::nothrow) std::vector<uint8_t>(*rhs.
seq);
166 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
175 real =
new(std::nothrow) std::vector<double>(*rhs.
real);
177 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
186 mask =
new(std::nothrow) std::vector<int>(*rhs.
mask);
188 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
261 seq =
new(std::nothrow) std::vector<uint8_t>(*rhs.
seq);
263 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
272 real =
new(std::nothrow) std::vector<double>(*rhs.
real);
274 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
283 mask =
new(std::nothrow) std::vector<int>(*rhs.
mask);
285 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
303 return (*
seq)[position];
306 std::cerr <<
"sequence has not been digitized. \n";
311 std::cerr <<
"Invalid sequence type queried in sequence class" <<std::endl;
322 return (*
real)[position];
325 std::cerr <<
"Values have not been imported.\n";
330 std::cerr <<
"Invalid sequence type queried in sequence class" <<std::endl;
349 for(
size_t i=0;i<
length;i++){
354 for(
size_t i=0;i<
length;i++){
362 for(
size_t i=0;i<
length;i++){
392 for (
size_t i=0;i<
length;i++){
400 std::cerr <<
"Track is not defined. Can't undigitize sequence without valid track\n";
427 while(file.peek() !=
'>'){
429 getline(file,temp,
'\n');
432 std::cerr <<
"Sequence doesn't contain a header \">\" "<< std::endl;
437 getline(file,
header,
'\n');
441 while(getline(file,line,
'\n')){
444 char nl_peek=file.peek();
449 else if (nl_peek==
'['){
452 std::cerr <<
"Found brackets [] in fasta sequence.\nHEADER: " <<
header <<
"\nCan't import External Definitions without stateInfo from HMM model. Pass stateInfo from model to " << __FUNCTION__ << std::endl;
461 else if (nl_peek==EOF){
462 getline(file,line,
'\n');
488 while(file.peek() !=
'>'){
490 getline(file,temp,
'\n');
493 std::cerr <<
"Sequence doesn't contain a header \">\" "<< std::endl;
499 std::string line, mask_string;
501 getline(file,
header,
'\n');
509 getline(file,mask_string,
'\n');
523 mask=
new(std::nothrow) std::vector<int>;
525 std::cerr <<
"OUT OF MEMORY\nFile" << __FILE__ <<
"Line:\t"<< __LINE__ << std::endl;
530 std::cerr <<
"Mask length not equal to Sequence length." << std::endl;
549 std::cerr <<
"Can't digitize sequence without a valid track defined\n";
561 seq =
new std::vector<uint8_t>(lst.
size());
567 for (
size_t i=0;i<lst.
size();i++){
630 while(file.peek() !=
'@' && file.good()){
632 getline(file,temp,
'\n');
637 getline(file,
header,
'\n');
647 while(getline(file,sequence,
'\n')){
650 char nl_peek=file.peek();
654 else if (nl_peek==EOF){
668 std::string quality_string;
672 while(getline(file,sequence,
'\n')){
675 char nl_peek=file.peek();
683 else if (nl_peek==EOF){
714 while(file.peek() !=
'@' && !file.eof()){
716 getline(file,temp,
'\n');
720 std::cerr <<
"No header found for sequence. Header should start line with \"@\".\n";
725 getline(file,sequence,
'\n');
731 while(getline(file,line,
'\n')){
734 for(
size_t i=0;i<temp.size();i++){
735 real->push_back(temp[i]);
738 char nl_peek=file.peek();
743 else if (nl_peek==
'['){
746 std::cerr <<
"Found brackets [] in fasta sequence.\nHEADER: " <<
header <<
"\nCan't import External Definitions without stateInfo from HMM model. Pass stateInfo from model to " << __FUNCTION__ << std::endl;
755 else if (nl_peek==EOF){
773 return (*
mask)[position];
776 std::cerr <<
"Position exceeds sequence length.\n";
781 std::cerr <<
"No Mask information.\n";
825 std::cerr <<
"Can't get symbol of real values\n";
830 std::cerr <<
"track is undefined for sequence\n";
905 std::cerr <<
"No sequence is defined to reverse\n";
909 std::cerr <<
"Reverse on undigitized sequence isn't defined for track alphabets that are more than one character\n";
921 std::cerr<<
"sequence::complement isn't defined for real valued sequences\n";
924 std::cerr <<
"StochHMM::track is not defined. Can't complement without defined complement in track\n";
928 for (
size_t i = 0; i <
seq->size(); i++) {
936 if (undigitized_size>0){
939 for(
size_t i=0;i<undigitized_size;i++){
947 std::cerr <<
"Complement on undigitized sequence isn't defined for track alphabets that are more than one character\n";
952 std::cerr <<
"No sequence defined\n";
964 std::cerr <<
"Unable to perform reverseComplement on sequence because reverse failed\n";
968 std::cerr <<
"Unable to perform reverseComplement on sequence because complement failed\n";
984 std::cerr <<
"Digitized sequence already exists\n";
988 std::cerr <<
"No undigitized sequence exists to convert\n";
997 std::random_shuffle(
real->begin(),
real->end());
1000 std::random_shuffle(
seq->begin(),
seq->end());
1014 std::cerr <<
"Track is not defined" << std::endl;
1019 size_t freqSize=freq.size();
1021 if (alphaSize!=freqSize){
1022 std::cerr <<
"Frequency distribution size and Alphabet size must be the same." << std::endl;
1027 std::vector<std::pair<double,std::string> > cdf;
1029 for(
size_t i=0;i<freqSize;++i){
1031 std::pair<double,std::string> val (sum, tr->
getAlpha(i));
1036 std::string random_string;
1037 for(
size_t j=0;j<length;++j){
1038 double val = ((double)rand()/((double)(RAND_MAX)+(double)(1)));
1039 for (
size_t m=0;m<freqSize;++m){
1040 if (cdf[m].first>=val){
1041 random_string+=cdf[m].second;
1047 random_seq.
setSeq(random_string, tr);