90 cout << endl <<
"Sequences:" << endl << endl;
92 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
93 cout <<
"Molecule " << mol->
id <<
": " << mol->
nbase <<
" nucleotides, "
94 << mol->
nres <<
" residues" << endl;
97 for ( maxnum=mol->
nres, res = mol->
res; res; res = res->
next )
98 if ( maxnum < res->num ) maxnum = res->
num;
101 for ( res = mol->
res; res; res = res->
next )
105 }
else if ( mol->
seq.
length() ) cout << mol->
seq << endl;
107 for ( maxnum=0, sec=mol->
sec; sec; sec=sec->
next )
108 if ( maxnum < sec->last->num ) maxnum = sec->
last->
num;
111 for ( sec=mol->
sec; sec; sec=sec->
next ) {
113 for ( i=sec->
first->
num-1; i<sec->last->num; i++ ) seq[i] =
'H';
115 for ( i=sec->
first->
num-1; i<sec->last->num; i++ ) seq[i] =
'E';
142 cout <<
"Calculating molecular weights:" << endl << endl;
144 cout <<
"Molecule\tMass" << endl;
145 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
149 for ( i=0; i<n; i++ ) {
150 for ( rt = rt_list; rt && rt->
c != mol->
seq[i]; rt = rt->
next ) ;
151 if ( rt ) mass += rt->
mass;
153 }
else if ( mol->
res ) {
154 for ( res = mol->
res; res; res = res->
next ) {
155 for ( rt = rt_list; rt && rt->
cod != res->
type; rt = rt->
next ) ;
156 if ( rt ) mass += rt->
mass;
160 cout << mol->
id <<
tab << mass << endl;
178 long i, j, n, nat, natr;
184 vector<double> el(5,0), elr(5,0), elall(5,0), el1(5,0);
187 cout <<
"Calculating the elemental composition:" << endl << endl;
189 cout <<
"Molecule\tH\tC\tN\tO\tS\tTotal" << endl;
190 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
191 for ( j=0; j<5; ++j ) el[j] = elr[j] = 0;
194 for ( i=0; i<n; i++ ) {
195 for ( rt = rt_list; rt && rt->
c != mol->
seq[i]; rt = rt->
next ) ;
196 if ( rt )
for ( j=0; j<5; ++j ) el[j] += rt->
comp[j];
208 for ( res = mol->
res; res; res = res->
next ) {
210 for ( rt = rt_list; rt && rt->
c != c1; rt = rt->
next ) ;
211 for ( j=0; j<5; ++j ) el1[j] = 0;
212 for ( atom = res->
atom; atom; atom = atom->
next )
if ( atom->
el[1] == 0 ) {
213 if ( atom->
el[0] ==
'H' ) elr[0]++;
214 if ( atom->
el[0] ==
'C' ) elr[1]++;
215 if ( atom->
el[0] ==
'N' ) elr[2]++;
216 if ( atom->
el[0] ==
'O' ) elr[3]++;
217 if ( atom->
el[0] ==
'S' ) elr[4]++;
218 if ( atom->
el[0] ==
'H' ) el1[0]++;
219 if ( atom->
el[0] ==
'C' ) el1[1]++;
220 if ( atom->
el[0] ==
'N' ) el1[2]++;
221 if ( atom->
el[0] ==
'O' ) el1[3]++;
222 if ( atom->
el[0] ==
'S' ) el1[4]++;
233 for ( j=nat=natr=0; j<5; ++j ) {
237 cout <<
tab << el[j];
239 cout <<
tab << nat << endl;
246 for ( j=n=0; j<5; n+=elall[j], ++j ) cout <<
tab << elall[j];
247 cout <<
tab << n << endl <<
"Percentage:";
248 for ( j=0; j<5; ++j ) cout <<
tab << elall[j]*100.0/n;
249 cout << endl << endl;
270 cout << endl <<
"Complementing all nucleotide sequences" << endl << endl;
272 for ( mol = molgroup->
mol; mol; mol = mol->
next )
296 cout << endl <<
"Translating all nucleotide sequences to amino acid sequences in frame " << frame << endl << endl;
322 cout <<
"Searching for: " << sseq << endl << endl;
324 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
326 if ( mol_naseq.
length() ) {
327 offset = mol_naseq.
find(sseq, 0);
329 cout << mol->
id <<
": " << offset << endl;
330 for ( i=0; i<offset; i++ ) cout <<
" ";
331 cout << sseq << endl << mol_naseq << endl;
334 offset = mol_naseq.
find(sseq, 0);
336 cout << mol->
id <<
": " << offset <<
" (complement)" << endl;
337 for ( i=0; i<offset; i++ ) cout <<
" ";
338 cout << sseq << endl << mol_naseq << endl;
340 cout << mol->
id <<
": not found" << endl;
344 cout <<
"Molecule " << mol->
id <<
": Nucleic acid sequence not found" << endl;
364 cout <<
"Searching for: " << sseq << endl << endl;
366 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
369 offset = mol_seq.
find(sseq, 0);
370 if ( offset > -1 ) cout << mol->
id <<
": " << offset << endl;
371 else cout << mol->
id <<
": not found" << endl;
373 cout <<
"Molecule " << mol->
id <<
": Protein sequence not found" << endl;
395 int side1,
int side2,
double threshold,
Bstring& gcfile)
398 if ( n < 1 )
return "";
402 if ( seqlenmin < n/2 ) seqlenmin = n/2;
403 if ( seqlenmax <= n ) seqlenmin = 2*n;
406 int f, i, j, nres = 0, start,
length, frame, term, seqlen = 0;
407 int bestscore = 0, bestframe = 0;
408 int bestindex = 0, bestseqlen = 0;
409 int* score = (
int *) malloc(
sizeof(
int));
412 snprintf(format, 100,
"%%.%ds%c", linelength,
'\n');
417 cout << endl <<
"Finding an amino acid sequence in translated nucleotide sequences:" << endl;
418 cout <<
"Sequence length range: " << seqlenmin <<
" - " << seqlenmax << endl;
419 cout <<
"Score threshold (residues): " << threshold << endl;
422 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
423 for ( f=0; f<6; f++ ) {
432 score = (
int *) realloc(score, nres*
sizeof(
int));
433 memset(score, 0, nres*
sizeof(
int));
435 for ( i=0; i<=nres - n; i++ ) {
436 if ( i == 0 || aaseq[i] ==
'*' ) {
438 while ( ( i+seqlen+1 < nres ) && ( aaseq[i+seqlen+1] !=
'*' ) )
441 if ( seqlen >= seqlenmin && seqlen <= seqlenmax ) {
443 for ( j=0; j<n && j<nres && !term; j++ ) {
444 if ( aaseq[i+j] == seq[j] ) score[i]++;
445 if ( aaseq[i+j] ==
'*' ) term = 1;
447 if ( !term && threshold > 0 && score[i] >= threshold ) {
449 cout <<
"Frame: " << f <<
" Position: " << 3*i + frame <<
450 " Length: " << seqlen <<
" Score: " << score[i] <<
451 " (" << score[i]*100.0/seq.
length() <<
" %)" << endl;
452 for ( j=0; j<n; j+= linelength )
453 printf(format, &aaseq[i + j]);
455 if ( !term && bestscore < score[i] ) {
456 bestscore = score[i];
460 bestindex = 3*i + frame;
461 start = (i - side1)*3 + frame;
462 while ( start < 0 ) start += 3;
463 length = (n + side1 + side2)*3;
475 cout <<
"Best sequence =" << bestseq << endl;
478 cout << endl <<
"Best sequence score: " << bestscore <<
479 " (" << bestscore*100.0/seq.
length() <<
"%)" << endl;
480 cout <<
"Molecule: " << bestmol->
id << endl;
481 cout <<
"Length: " << bestseqlen << endl;
482 if ( bestframe < 3 ) cout <<
"Frame: " << bestframe << endl;
483 else cout <<
"Frame: " << bestframe - 3 <<
" (complement)" << endl;
484 cout <<
"Index: " << bestindex << endl;
485 cout <<
"Nucleotide sequence:" << endl;
486 for ( i=0; i<bestseq.
length(); i+= linelength )
487 printf(format, bestseq.
c_str() + i);
489 cout <<
"Amino acid sequence:" << endl;
490 for ( i=0; i<aaseq.
length(); i+= linelength )
491 printf(format, aaseq.
c_str() + i);
492 cout <<
"Requested sequence:" << endl;
493 for ( i=0; i<seq.
length(); i+= linelength )
494 printf(format, seq.
c_str() + i);
515 for (
int i=0; i<3; ++i ) cod[i] = rc[i];
518 cout <<
"DEBUG getcode3: c=" << c <<
" cod=" << cod << endl;
536 for ( i=0; i<3 && i<strlen(acode); i++ ) acode[i] = toupper(acode[i]);
540 if ( it->second == acode ) c = it->first;
556 for ( i=0; i<(j+1)/2; i++ ) {
575 case 'A': nunuc =
'T';
break;
576 case 'G': nunuc =
'C';
break;
577 case 'C': nunuc =
'G';
break;
578 case 'T': nunuc =
'A';
break;
579 case 'U': nunuc =
'A';
break;
596 long nnuc = nucseq.
length();
597 long nres = (nnuc - frame)/3;
600 for ( i=0, j=frame; i<nres && j<nnuc; i++, j+=3 )
603 if ( i < nres ) aaseq[i] = 0;