 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
45 cout <<
"Elements processed: " << n << endl << endl;
66 n += (modfunc)(mp, i);
69 cout <<
"Elements processed: " << n << endl << endl;
90 n += (modfunc)(mp, d);
93 cout <<
"Elements processed: " << n << endl << endl;
114 n += (modfunc)(mp, str);
117 cout <<
"Elements processed: " << n << endl << endl;
129 if ( !
model )
return 0;
136 cout <<
"Model\tType\tNcomp\tPG\tHand\tFOM\tSelect\tMap\tNumber" << endl;
137 for ( mp =
model; mp; mp = mp->
next, nmod++ ) {
138 for ( ncomp=0, comp = mp->
comp; comp; comp = comp->
next ) ncomp++;
160 if ( !
model )
return 0;
162 long i, nmod(0), nct(0);
171 for ( mp =
model; mp; mp = mp->
next, nmod++ )
if ( mp->
sel ) {
172 for ( ct = mp->
type; ct; ct = ct->
next ) {
173 for ( type = comptypelist; type && *type != ct->
id; type = type->
next ) ;
176 if ( !comptypelist ) comptypelist = comptype;
182 int* n =
new int[nct];
183 int* ntot =
new int[nct];
184 for ( i=0; i<nct; i++ ) ntot[i] = 0;
187 for ( comptype = comptypelist; comptype; comptype = comptype->
next )
188 cout <<
tab << *comptype;
192 for ( i=0; i<nct; i++ ) n[i] = 0;
193 for ( comp = mp->
comp; comp; comp = comp->
next )
if ( comp->
sel ) {
194 for ( i=0, comptype = comptypelist; comptype && *comptype != comp->
type->
id; comptype = comptype->
next, i++ ) ;
195 if ( comptype ) n[i]++;
198 for ( i=0, comptype = comptypelist; comptype; comptype = comptype->
next, i++ ) {
207 for ( i=0, comptype = comptypelist; comptype; comptype = comptype->
next, i++ )
208 cout <<
tab << ntot[i];
209 cout << endl << endl;
241 cout <<
"Replacing components in a model from a reference model: " << modref->
id << endl;
250 mp->
type = ct = NULL;
251 mp->
comp = comp = NULL;
252 mp->
link = link = NULL;
253 mp->
poly = poly = NULL;
254 for ( ctref = modref->
type; ctref; ctref = ctref->
next ) {
259 for ( compref = modref->
comp; compref; compref = compref->
next ) {
265 for ( linkref = modref->
link; linkref; linkref = linkref->
next ) {
267 if ( !modref->
link ) modref->
link = link;
268 for ( compref = modref->
comp, comp = mp->
comp; compref; compref = compref->
next, comp = comp->
next ) {
269 if ( linkref->
comp[0] == compref ) link->
comp[0] = comp;
270 if ( linkref->
comp[1] == compref ) link->
comp[1] = comp;
274 for ( i=0; i<4; i++ ) link->
color[i] = linkref->
color[i];
276 for ( polyref = modref->
poly; polyref; polyref = polyref->
next ) {
278 if ( !modref->
poly ) modref->
poly = poly;
282 for ( compref = modref->
comp, comp = mp->
comp; compref; compref = compref->
next, comp = comp->
next ) {
283 for ( i=0; polyref->
comp[i]; i++ )
284 if ( polyref->
comp[i] == compref ) poly->
comp[i] = comp;
301 if ( !
model )
return 0;
303 long nct, ncomp, nlink;
309 if ( comp )
for ( ; comp->
next; comp = comp->
next ) ;
310 if ( link )
for ( ; link->
next; link = link->
next ) ;
316 if ( ct )
for ( ; ct->
next; ct = ct->
next ) ;
320 if ( comp )
for ( ; comp->
next; comp = comp->
next ) ;
324 if ( link )
for ( ; link->
next; link = link->
next ) ;
336 for ( nlink=0, link =
model->
link; link; link = link->
next ) nlink++;
339 cout <<
"Merged component types: " << nct << endl;
340 cout <<
"Merged components: " << ncomp << endl;
341 cout <<
"Merged links: " << nlink << endl;
358 if ( !
model )
return 0;
380 if ( !
model )
return 0;
399 for ( i=0; comp->
link[i]; i++ ) ;
420 if ( !
model )
return mass;
428 if ( ct ) mass += ct->
mass;
432 cout <<
"Model: " <<
model->
id <<
" Mass = " << mass << endl;
450 cout <<
"Model\tMass" << endl;
479 if ( !
model )
return com;
505 if ( !
model )
return 0;
514 for ( n = 0, R = 0, comp =
model->
comp; comp; comp = comp->
next )
if ( comp->
sel ) {
520 if ( n ) R = sqrt(R/n);
538 if ( !
model )
return eigenval;
551 vecx[0] += loc[0]*loc[1];
552 vecx[1] += loc[0]*loc[2];
553 vecx[2] += loc[1]*loc[2];
558 cout <<
"Model: " <<
model->
id << endl;
559 cout <<
"Number of components: " << summass << endl;
563 cout <<
"Error: No components found!" << endl << endl;
576 if ( !
model )
return -1;
582 cout <<
"Principal axes:" << endl <<
"Model\tMajor\tMiddle\tMinor" << endl;
586 cout << mp->
id <<
tab << pax[0] <<
tab << pax[1] <<
tab << pax[2] << endl;
607 if ( interval <= 0 ) interval = 1;
608 if ( !
model )
return 0;
615 min = min.min(comp1->
loc);
616 max = max.
max(comp1->
loc);
619 int r, rmax = (int) (max.
distance(min)/interval + 1);
621 int* rdf =
new int[rmax];
622 for ( r=0; r<rmax; r++ ) rdf[r] = 0;
625 for ( comp2 = comp1->
next; comp2; comp2 = comp2->
next )
if ( comp2->
sel ) {
627 r = (int) (d/interval + 0.5);
628 if ( r < rmax ) rdf[r]++;
633 cout <<
"Radius\tCount" << endl;
634 for ( r=0; r<rmax; r++ )
635 cout << r*interval <<
tab << rdf[r] << endl;
651 long vol = (long) size.
volume();
652 char* tgrid =
new char[vol];
653 for ( i=0; i<vol; i++ ) tgrid[i] = 0;
655 for ( mol=molgroup->
mol; mol; mol=mol->
next ) {
656 for ( res=mol->
res; res; res=res->
next ) {
657 for ( atom=res->
atom; atom; atom=atom->
next ) {
658 x = (int) ((atom->
coord[0] - min[0])/sampling);
659 y = (int) ((atom->
coord[1] - min[1])/sampling);
660 z = (int) ((atom->
coord[2] - min[2])/sampling);
661 i = (z*size[1]+y)*size[0]+x;
662 if ( i < 0 || i > vol ) {
663 cerr <<
"Error in molgroup_write_into_grid: i=" << i <<
" (vol=" << vol <<
")" << endl;
671 for ( i=0; i<vol; i++ ) grid[i] += tgrid[i];
707 cout <<
"Assembling components" << endl;
709 for ( nsel=0, comp =
model->
comp; comp; comp = comp->
next )
if ( comp->
sel ) {
715 min -= molgroup1->
box;
716 max += molgroup1->
box;
718 for ( i=0; i<3; i++ ) size[i] = (
int) ((max[i] - min[i])/sampling);
721 cerr <<
"Error: No components are selected!" << endl;
725 long vol = (long) size.
volume();
726 int* grid =
new int[vol];
727 for ( i=0; i<vol; i++ ) grid[i] = 0;
729 for ( nsel=0, comp =
model->
comp; comp; comp = comp->
next )
if ( comp->
sel ) {
733 molgroup1->
id = comp->
id;
743 error_show(
"Error in model_assemble", __FILE__, __LINE__);
747 if ( !mglist ) mglist = molgroup = molgroup1;
749 molgroup->
next = molgroup1;
750 molgroup = molgroup1;
755 for ( ; mol->
next; mol = mol->
next ) ;
758 mol = molgroup->
mol = molgroup1->
mol;
760 molgroup1->
mol = NULL;
763 mglist = molgroup = molgroup1;
769 for ( i=nover=0; i<vol; i++ )
if ( grid[i] > 1 ) nover++;
774 cout <<
"Components assembled: " << nsel << endl;
775 cout <<
"Molecule group overlap: " <<
776 sampling*sampling*sampling*nover <<
" A3 (" << nover*100.0/size.
volume() <<
" %)" << endl << endl;
803 cout <<
"Generating a centers-of-mass model" << endl << endl;
805 for ( i=1, mg = molgroup; mg; mg = mg->
next, i++ ) {
811 for ( j=1, mol = molgroup->
mol; mol; mol = mol->
next, j++, n++ ) {
812 cout <<
"Adding molecule " << j <<
" as component" << endl;
822 cout <<
"Models generated: " << --i << endl;
823 cout <<
"Components generated: " << n << endl << endl;
846 cout <<
"Updating component centers-of-mass" << endl << endl;
848 for ( nsel=0, comp =
model->
comp; comp; comp = comp->
next )
if ( comp->
sel ) {
850 for ( mg = molgroup; mg; mg = mg->
next )
if ( comp->
id == mg->
id )
break;
873 cout <<
"Averaging every " << number <<
" of selected components" << endl;
877 for ( comp = mp->
comp; comp; comp = comp->
next )
if ( comp->
sel ) {
883 comp_avg->
loc += comp->
loc;
885 if ( comp_avg->
sel == number ) {
886 comp_avg->
loc /= comp_avg->
sel;
890 }
else comp->
sel = 1;
891 if ( comp_avg ) comp_avg->
loc /= comp_avg->
sel;
908 for ( n=0, mp =
model; mp; mp = mp->
next )
if ( mp->
sel )
909 for ( comp = mp->
comp; comp; comp = comp->
next )
if ( comp->
sel ) n++;
913 for ( n=0, mp =
model; mp; mp = mp->
next )
if ( mp->
sel )
914 for ( comp = mp->
comp; comp; comp = comp->
next )
if ( comp->
sel )
915 comparray[n++] = comp;
940 for ( i=0; i<3; i++ ) b[i] = 0;
943 for ( n=0; n<
MAXLINK && comparray[n]; n++ ) {
944 loc = comparray[n]->loc;
946 for ( i=0; i<3; i++ ) {
947 for ( j=0; j<=i; j++ )
948 a[3][i] += loc[i]*loc[j];
954 for ( i=1; i<3; i++ )
955 for ( j=0; j<i; j++ )
959 if ( a[0][0] == 0 ) {
961 }
else if ( a[1][1] == 0 ) {
963 }
else if ( a[2][2] == 0 ) {
971 offset = center.
scalar(normal);
long model_list(Bmodel *model)
Lists models in table form.
long molgroup_write_into_grid(Bmolgroup *molgroup, Vector3< int > size, Vector3< double > min, double sampling, int *grid)
long molgroup_stats(Bmolgroup *molgroup, int show)
Calculates the statistics of a molecule group.
int model_check(Bmodel *model, Bstring path)
Checks model properties.
Header file for matrix functions.
Utility functions for matrices.
long model_radial_distribution(Bmodel *model, double interval)
Calculates the radial distribution function of a model.
Vector3< double > mol_center_of_mass(Bmolecule *mol)
Calculates the center of mass of a molecule.
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
long model_replace_components(Bmodel *model, Bmodel *modref)
Replaces all components in a model with reference components.
Vector3< double > model_center_of_mass(Bmodel *model)
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
Vector3< double > component_plane(Bcomponent **comparray, double &offset)
Calculates a plane through an array of components.
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
Header file for general symmetry functions.
Header file for functions for creating random images.
3x3 Matrix manipulation functions
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Bmolgroup * read_molecule(const char *filename, const char *select, const char *paramfile)
The generalized function for reading molecular files.
Bcomponent ** component_get_array(Bmodel *model, long &n)
Generates an array of pointers to component structures.
Vector3< double > principal_axes(Vector3< double > avg, Vector3< double > avg2, Vector3< double > avgx, Vector3< double > *eigenvec)
Calculates the principal axes of 3D coordinates.
int comp_type_list_kill(Bcomptype *type)
Deallocates memory for a list of component types.
double scalar(const Vector3 &v) const
double length(vector< T > v)
long count_list(char *list)
Counts the number of items in a linked list.
Library routines used for model link processing.
int component_list_kill(Bcomponent *comp)
Deallocates memory for a list of components.
double distance(const Vector3 &v)
Bmodel * model_generate_com(Bmolgroup *molgroup)
Calculates the centers-of-mass of molecule group components and generates a new model.
Vector3< double > model_principal_axes(Bmodel *model, Vector3< double > *eigenvec)
Calculates the principal axes of a model.
Bcomptype * model_add_type_by_id_and_filename(Bmodel *model, Bstring &id, Bstring &filename, int num)
Add a type to a model if the type with the given id and file name does not exist already.
long model_delete_non_selected(Bmodel **model)
Deletes selected components and associated links from the model.
int model_kill(Bmodel *model)
Deallocates all memory in the list.
Header file for reading and writing atomic model files.
double LU_decomposition()
Matrix inversion by LU decomposition.
double model_mass(Bmodel *model)
Calculates the mass of a model from component masses.
long model_average_components(Bmodel *model, int number)
Averages sequential components.
Library routines used to compare sets of atomic coordinates.
long models_process(Bmodel *model, long(modfunc)(Bmodel *))
Process a list of models using the specified function.
long model_list_comp(Bmodel *model)
Lists models with component counts in table form.
Header file for general utilities.
ostream & tab(ostream &out)
long model_update_centers_of_mass(Bmodel *model, Bmolgroup *molgroup)
Updates the centers-of-mass of molecule group components.
Bcomponent * comp[MAXLINK]
Vector3< double > molgroup_center_of_mass(Bmolgroup *molgroup)
Calculates the center of mass of a molecule group.
Vector3< double > model_center_of_mass_nu(Bmodel *model)
Calculates the center-of-mass of a model.
long model_rename_components(Bmodel *model)
Rename components.
Bmolgroup * model_assemble(Bmodel *model, Bstring ¶mfile, int separate)
Concatenates selected molecules into one group.
Header file for generalized linked list functions.
int poly_list_kill(Bpolygon *poly)
Deallocates memory for a list of polygons.
Library routines used for model processing.
Bcomptype * model_add_type_by_id(Bmodel *model, Bstring &id)
Add a type to a model if the identifier does not exist already.
long model_merge(Bmodel *model)
Merges components from all models into one.
double model_gyration_radius(Bmodel *model)
Calculates the radius of gyration for a model.
long model_setup_links(Bmodel *model)
Set up the link list for each component.
int component_type_copy(Bcomptype *fromct, Bcomptype *toct)
Copies all elements from one component to another.
int component_copy(Bcomponent *fromcomp, Bcomponent *tocomp)
Copies all elements from one component to another.
int model_link_list_kill(Bmodel *model)
Deallocates memory for a list of component links.
long model_number_ids(Bmodel *model)
Add a number to each model id.
Bcomponent * link[MAXLINK]
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
long model_mass_all(Bmodel *model)
Calculates the masses of all the models in the list.
Library routines used for atomic coordinates.