31 double avgB = 0, sdB = 0, atomB = 0, dist, maxdist = 0;
39 cout <<
"Residue\tNatoms\tAvgB\tStDevB" << endl;
41 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
42 for( res = mol->
res; res; res = res->
next ) {
45 for ( atom = res->
atom; atom; atom = atom->
next ) {
48 sdB += atom->
b*atom->
b;
51 sdB = sqrt(sdB/nat - avgB*avgB);
52 cout << res->
num <<
tab << nat <<
tab << avgB <<
tab << sdB << endl;
57 cout <<
"Residue\tMaxDist\tBfactor\tAtom" << endl;
59 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
60 for( res = mol->
res; res; res = res->
next ) {
61 for ( atom = res->
atom; atom; atom = atom->
next ) {
62 if ( strstr(atom->
type,
"CA" ) ) {
64 strncpy(atomtype, atom->
type, 8);
66 }
else if ( strncmp(atom->
type,
"H", 1 ) &&
67 strncmp(atom->
type,
" H", 2 ) &&
68 !strstr(atom->
type,
"N " ) &&
69 !strstr(atom->
type,
"C " ) &&
70 !strstr(atom->
type,
"O " ) ) {
72 if ( maxdist < dist ) {
74 strncpy(atomtype, atom->
type, 8);
79 cout << res->
num <<
tab << maxdist <<
tab << atomB <<
tab << atomtype << endl;
97 cout <<
"Sequence:" << endl;
99 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
100 cout <<
"Molecule: " << mol->
id << endl << mol->
seq << endl;
102 cout << endl <<
"Length = " << mol->
nres << endl << endl;
116 if ( radius < 0.1 )
return 0;
119 double dist, sum, sumsq, avg, std;
125 cout <<
"Shifting to radius: " << radius << endl << endl;
127 for ( sum=sumsq=natom=0, mol = molgroup->
mol; mol; mol = mol->
next ) {
128 for( res = mol->
res; res; res = res->
next ) {
129 for ( atom = res->
atom; atom; atom = atom->
next, natom++ ) {
133 atom->
coord *= radius/dist;
139 std = sumsq/natom - avg*avg;
140 if ( std > 0 ) std = sqrt(std);
144 cout <<
"Radius avg and std: " << avg <<
" " << std << endl << endl;
163 if ( first_name == 0 )
return 0;
165 char letter = first_name;
168 for ( mol=molgroup->
mol; mol; mol=mol->
next ) {
169 mol->
id[0] = letter++;
170 if ( letter >
'Z' ) letter =
'A';
184 if ( first < 1 )
return 0;
191 cout <<
"Renumbering residues from: " << first << endl;
193 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
195 for( res = mol->
res; res; res = res->
next ) {
213 if ( first < 1 )
return 0;
221 cout <<
"Renumbering atoms from: " << first << endl;
223 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
224 for( res = mol->
res; res; res = res->
next ) {
225 for ( atom = res->
atom; atom; atom = atom->
next ) {
244 int range_last,
double occupancy)
251 cout <<
"Reseting occupancy to range: " << range_first <<
" " <<range_last << endl;
253 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
254 for( res = mol->
res; res; res = res->
next ) {
255 if ( res->
num >= range_first && res->
num <= range_last )
256 for ( atom = res->
atom; atom; atom = atom->
next ) {
273 double summass(0), totmass = 0;
279 cout <<
"Molecule\tMW(Da)\tAtoms" << endl;
280 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
283 for( res = mol->
res; res; res = res->
next ) {
284 for ( atom = res->
atom; atom; atom = atom->
next ) {
286 summass += atom->
mass;
290 cout << mol->
id <<
tab << summass <<
tab << n << endl;
295 cout <<
"Total molecular weight: " << totmass <<
" Da" << endl;
296 cout <<
"Total volume: " << totmass/
RHO <<
" A3" << endl << endl;
315 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
316 for( res = mol->
res; res; res = res->
next ) {
317 for ( atom = res->
atom; atom; atom = atom->
next ) {
320 vec += acoord*acoord;
321 summass += atom->
mass;
328 vec = vec/summass - com*com;
331 }
else cout <<
"Error: No atom masses found!" << endl << endl;
334 cout <<
"Total molecular weight: " << summass <<
" Da" << endl;
335 cout <<
"Center of mass: " << com <<
" A" << endl;
336 cout <<
"Major axis: " << vec << endl;
355 for ( mol = molgroup->
mol; mol; mol = mol->
next )
if ( mol->
sel ) {
356 for( res = mol->
res; res; res = res->
next ) {
357 for ( atom = res->
atom; atom; atom = atom->
next )
if ( atom->
sel ) {
360 vec += acoord*acoord;
361 summass += atom->
mass;
368 vec = vec/summass - com*com;
371 }
else cout <<
"Error: No atom masses found!" << endl << endl;
374 cout <<
"Total molecular weight: " << summass <<
" Da" << endl;
375 cout <<
"Center of mass: " << com <<
" A" << endl;
376 cout <<
"Major axis: " << vec << endl;
391 cout <<
"Center of mass: " << com <<
" A" << endl;
408 for( res = mol->
res; res; res = res->
next ) {
409 for ( atom = res->
atom; atom; atom = atom->
next ) {
412 vec += acoord*acoord;
413 summass += atom->
mass;
419 vec = vec/summass - com*com;
422 }
else cerr <<
"Error: No atom masses found!" << endl << endl;
425 cout <<
"Molecule: " << mol->
id << endl;
426 cout <<
"Molecular weight: " << summass <<
" Da" << endl;
427 cout <<
"Center of mass: " << com <<
" A" << endl;
428 cout <<
"Major axis: " << vec << endl << endl;
443 cout <<
"Molecule: " << mol->
id << endl;
444 cout <<
"Center of mass: " << com <<
" A" << endl;
463 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
465 for( res = mol->
res; res; res = res->
next ) {
466 for ( atom = res->
atom; atom; atom = atom->
next ) {
472 summass += atom->
mass;
478 cout <<
"Molecule group:" << endl;
479 cout <<
"Molecular weight: " << summass <<
" Da" << endl;
483 cout <<
"Error: No atom masses found!" << endl << endl;
507 for( res = mol->
res; res; res = res->
next ) {
508 for ( atom = res->
atom; atom; atom = atom->
next ) {
514 summass += atom->
mass;
519 cout <<
"Molecule: " << mol->
id << endl;
520 cout <<
"Molecular weight: " << summass <<
" Da" << endl;
524 cout <<
"Error: No atom masses found!" << endl << endl;
547 if ( da > 1 ) da *=
M_PI/180.0;
550 double t, p, dp, pm, st, dist, r, dm(0), avg(0), std(0), sph(0);
559 cout <<
"Calculating sphericity with a step size of "
560 << da*180.0/
M_PI <<
" degrees" << endl << endl;
564 for ( i = 0, t = 0; t <=
M_PI; t += da ) {
573 for ( j=0, p = 0; p<pm; p += dp, i++, j++ )
575 cout << i <<
tab << t <<
tab << p << endl;
579 cout << t <<
tab << n.back() <<
tab << na.back() << endl;
582 vector<long> d(i, 0);
584 for ( mol = molgroup->
mol; mol; mol = mol->
next )
585 for( res = mol->
res; res; res = res->
next )
586 for ( atom = res->
atom; atom; atom = atom->
next ) {
587 c = atom->
coord - com;
589 if ( dm < dist ) dm = dist;
591 j = long(t/da + 0.5);
592 if ( j >= n.size() ) j = n.size() - 1;
594 if ( i < 0 || i >= n.size() )
595 cerr <<
"i = " << i << endl;
599 r = sqrt(c[0]*c[0]+c[1]*c[1]);
602 p = atan2(c[1],c[0]);
605 if ( p < 0 ) p +=
TWOPI;
608 if ( k >= n[j] ) k -= n[j];
614 if ( i >= d.size() ) {
615 cerr <<
"Error: array out of bounds!" << endl;
616 cerr << i <<
tab << j <<
tab << k << endl;
618 if ( d[i] < dist ) d[i] = dist;
621 for ( i = 0; i < d.size(); ++i ) {
622 for ( j = 0; j < na.size() && na[j] <= i; ++j ) ;
623 if ( j ) k = i - na[j-1];
632 cout << i <<
tab << j <<
tab << t <<
tab << p <<
tab << d[i] << endl;
639 std = sqrt(std - avg*avg);
643 cout <<
"Number of solid angle bins: " << d.size() << endl;
644 cout <<
"Maximal distance: " << dm << endl;
645 cout <<
"Average bin maximal distance: " << avg << endl;
646 cout <<
"Standard deviation: " << std << endl;
647 cout <<
"Sphericity: " << sph << endl << endl;
668 long nmol, nres, natom;
674 for ( nmol=nres=natom=0, mol = molgroup->
mol; mol; mol = mol->
next, nmol++ )
675 for( res = mol->
res; res; res = res->
next, nres++ )
676 for ( atom = res->
atom; atom; atom = atom->
next, natom++ ) mass += atom->
mass;
680 double density = mass/
volume;
683 cout <<
"Number of molecules and atoms: " << nmol <<
" " << nres <<
" " << natom << endl;
684 cout <<
"Volume: " << molgroup->
box <<
" = " <<
volume <<
" A3" << endl;
685 cout <<
"Density: " << density <<
" Da/A3" << density*1.66058 <<
" g/ml" << endl;
686 cout <<
"Density: " << nmol*1.0/
volume <<
" molecules/A3 "
687 << nres*1.0/
volume <<
" residues/A3 " << natom*1.0/
volume <<
" atoms/A3" << endl << endl;
712 molgroup->
box = molgroup->
max - molgroup->
min;
714 long i, x, y, z, ix, iy, iz, rad;
715 double volume = 0, VdWvol = 0, mass = 0, resmass, sampling = 1, edge = 3, dist, dist2;
716 double voxel_volume = sampling*sampling*sampling;
719 if ( wrap ) edge = 0;
720 gridsize[0] = (int) ((molgroup->
max[0] - molgroup->
min[0] + 2*edge)/sampling + 1);
721 gridsize[1] = (int) ((molgroup->
max[1] - molgroup->
min[1] + 2*edge)/sampling + 1);
722 gridsize[2] = (int) ((molgroup->
max[2] - molgroup->
min[2] + 2*edge)/sampling + 1);
724 long size = (long) gridsize.
volume();
726 char* grid =
new char[size];
727 for ( i=0; i<size; i++ ) grid[i] = 0;
735 cout <<
"Calculating the Van der Waals volume:" << endl;
736 cout <<
" in volume: " << gridsize <<
" = " << size << endl;
737 if ( wrap ) cout <<
"with wrapping." << endl;
739 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
740 for( res = mol->
res; res; res = res->
next ) {
741 for ( atom = res->
atom, resmass=0; atom; atom = atom->
next ) {
742 resmass += atom->
mass;
743 for ( at = atompar; at && strncmp(atom->
el, at->
el, 2)!=0; at = at->
next ) ;
747 cout <<
"VdW distance too short! atom=" << atom->
el <<
" dist=" << at->
vdw << endl;
749 dist = at->
vdw/sampling;
752 rad = (long) (dist + 1);
756 lo =
Vector3<int>((
int)c[0], (
int)c[1], (
int)c[2]) - rad;
757 hi =
Vector3<int>((
int)c[0], (
int)c[1], (
int)c[2]) + rad;
760 hi = hi.
min(gridsize - 1);
762 for ( z=lo[2]; z<=hi[2]; z++ ) {
764 if ( iz < 0 ) iz += gridsize[2];
765 if ( iz >= gridsize[2] ) iz -= gridsize[2];
767 for ( y=lo[1]; y<=hi[1]; y++ ) {
769 if ( iy < 0 ) iy += gridsize[1];
770 if ( iy >= gridsize[1] ) iy -= gridsize[1];
772 for ( x=lo[0]; x<=hi[0]; x++ ) {
774 if ( ix < 0 ) ix += gridsize[0];
775 if ( ix >= gridsize[0] ) ix -= gridsize[0];
778 grid[(iz*gridsize[1] + iy)*gridsize[0] + ix] = 1;
784 for ( rt = respar; rt && strncmp(rt->
cod, res->
type, 3)!=0; rt = rt->
next ) ;
790 cout <<
"Mass: " << mass <<
" Da" << endl;
791 cout <<
"Volume from residue volumes: " <<
volume <<
" A3 (" <<
793 cout <<
"Density: " << mass/
volume <<
" Da/A3 "
794 << 1.66058*mass/
volume <<
" g/ml" << endl << endl;
796 for ( i=0, VdWvol=0; i<size; i++ ) VdWvol += grid[i];
797 VdWvol *= voxel_volume;
799 cout <<
"Van der Waals volume: " << VdWvol <<
" A3 ("
800 << VdWvol*100.0/(voxel_volume*size) <<
" %)" << endl;
801 cout <<
"Packing density: " << VdWvol/
volume << endl << endl;
821 long i, t, nel(0), nres(0), el[1024], an(0);
822 double mass[1024], mw(0), extinc(0);
830 for ( t=0, at = atompar; at && t < 1022; at = at->
next, t++ )
833 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
835 for ( i=0; i<mol->
seq.
length(); i++, nres++ ) {
836 if ( num.find(mol->
seq[i]) == num.end() )
837 num[mol->
seq[i]] = 1;
842 for( res = mol->
res; res; res = res->
next )
843 for ( atom = res->
atom; atom; atom = atom->
next ) {
851 for ( t=0, at = atompar; at && t < 1022; at = at->
next, t++ )
857 extinc += num[
'W'] * 5500;
858 extinc += num[
'Y'] * 1490;
860 extinc += num[
'F'] * 200;
863 cout <<
"Elemental composition:" << endl;
864 cout <<
"Element\tNumber\tMass" << endl;
865 for ( t=0, at = atompar; at && t < 1022; at = at->
next, t++ )
866 if ( el[t] ) cout << at->
el <<
tab << el[t] <<
tab << mass[t] << endl;
869 cout <<
"Total molecular weight: " << mw <<
" Da" << endl;
870 cout <<
"Total atomic number: " << an << endl << endl;
874 cout <<
"Residue composition:" << endl;
875 cout <<
"Residue\tNumber" << endl;
876 for (
auto it=num.begin(); it!=num.end(); ++it )
877 cout << it->first <<
tab << it->second << endl;
879 cout <<
"Extinction coefficient (280 nm): " << extinc <<
" /M/cm" << endl << endl;
900 for ( mol = molgroup->
mol; mol; mol = mol->
next )
901 for( res = mol->
res; res; res = res->
next )
902 for ( atom = res->
atom; atom; atom = atom->
next )
925 vector<double> el(5,0), eltot(5,0);
928 cout <<
"Calculating the elemental composition:" << endl << endl;
931 cout <<
"Molecule\tH\tC\tN\tO\tS\tTotal" << endl;
932 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
935 for ( rt = rt_list; rt && rt->
c != mol->
seq[i]; rt = rt->
next ) ;
937 for ( j=0; j<5; ++j )
938 el[j] += rt->
comp[j];
942 for ( j=n=0; j<5; ++j ) {
946 cout <<
tab << el[j];
950 cout <<
tab << n << endl;
954 for ( j=n=0; j<5; ++j ) {
957 cout <<
tab << eltot[j];
961 cout <<
tab << n << endl;
967 for ( j=0; j<5; ++j )
968 cout <<
tab << eltot[j]*100.0/n;
974 comp[
"H"] = eltot[0];
975 comp[
"C"] = eltot[1];
976 comp[
"N"] = eltot[2];
977 comp[
"O"] = eltot[3];
978 comp[
"S"] = eltot[4];
981 cout << comp << endl;
1001 double mc = comp[
"H"].
real() +
1002 12*comp[
"C"].
real() +
1003 14*comp[
"N"].
real() +
1004 16*comp[
"O"].
real() +
1005 32*comp[
"S"].
real();
1007 double sc = mass/mc;
1014 cout << comp << endl;
1032 int i, ii, j, x, y, z, xx, yy, zz, ix, iy, iz;
1033 int xlo, ylo, zlo, xhi, yhi, zhi;
1038 (
int) (box[1]/sampling[1] + 0.001), (
int) (box[2]/sampling[2] + 0.001));
1040 for ( i=0; i<3; i++ ) sampling[i] = box[i]/size[i] + 0.001;
1043 Latom *latom, *latom2;
1045 double mult = 1.0/interval;
1046 int n = (int) (mult*cutoff+1);
1047 int* rdf =
new int[n];
1048 for ( i=0; i<n; i++ ) rdf[i] = 0;
1050 for ( i=z=0; z<size[2]; z++ ) {
1054 if ( zlo < 0 ) zlo = 0;
1055 if ( zhi >= size[2] ) zhi = size[2] - 1;
1057 for ( y=0; y<size[1]; y++ ) {
1061 if ( ylo < 0 ) ylo = 0;
1062 if ( yhi >= size[1] ) yhi = size[1] - 1;
1064 for ( x=0; x<size[0]; x++, i++ ) {
1068 if ( xlo < 0 ) xlo = 0;
1069 if ( xhi >= size[0] ) xhi = size[0] - 1;
1071 for ( latom = alist[i]; latom; latom = latom->
next ) {
1072 for ( zz=zlo; zz<=zhi; zz++ ) {
1075 if ( iz < 0 ) iz += size[2];
1076 if ( iz >= size[2]) iz -= size[2];
1078 for ( yy=ylo; yy<=yhi; yy++ ) {
1081 if ( iy < 0 ) iy += size[1];
1082 if ( iy >= size[1] ) iy -= size[1];
1084 for ( xx=xlo; xx<=xhi; xx++ ) {
1087 if ( ix < 0 ) ix += size[0];
1088 if ( ix >= size[0] ) ix -= size[0];
1090 ii = (iz*size[1] + iy)*size[0] + ix;
1091 for ( latom2 = alist[ii]; latom2; latom2 = latom2->
next )
1092 if ( latom2->
atom != latom->
atom ) {
1095 if ( dist <= cutoff ) {
1096 j = (int) (mult*dist);
1097 if ( j < n ) rdf[j]++;
1108 for ( i=0; i<size.volume(); i++ )
kill_list((
char *) alist[i],
sizeof(
Latom));
1111 cout <<
"Calculating the radial distribution function within " << cutoff <<
" A" << endl;
1113 cout <<
"r(A)\tRDF" << endl;
1114 for ( i=0; i<n; i++ ) cout << i*interval <<
tab << rdf[i] << endl;
1138 long gridvol = (long) size.
volume();
1145 for ( i=0; i<gridvol; i++ ) alist[i] = alistp[i] = NULL;
1147 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
1148 for ( res = mol->
res; res; res = res->
next ) {
1149 for ( atom = res->
atom; atom; atom = atom->
next ) {
1150 x = (long) ((atom->
coord[0] - origin[0])/sampling[0]);
1151 y = (long) ((atom->
coord[1] - origin[1])/sampling[1]);
1152 z = (long) ((atom->
coord[2] - origin[2])/sampling[2]);
1156 if ( x >= size[0] ) x = size[0] - 1;
1157 if ( y >= size[1] ) y = size[1] - 1;
1158 if ( z >= size[2] ) z = size[2] - 1;
1159 i = (z*size[1] + y)*size[0] + x;
1161 alistp[i]->
atom = atom;
1162 if ( !alist[i] ) alist[i] = alistp[i];
1170 cout <<
"DEBUG molgroup_atom_mesh_lists: Done!" << endl;
1186 vector<Batom*> atomarray;
1188 for ( n=0, mol = molgroup->
mol; mol; mol = mol->
next )
if ( mol->
sel )
1189 for( res = mol->
res; res; res = res->
next )
1190 for ( atom = res->
atom; atom; atom = atom->
next, n++ )
1191 atomarray.push_back(atom);