 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
56 cout <<
"DEBUG read_model: extension=" << ext << endl;
75 cerr <<
"Error: File with extension " << ext <<
" not read!" << endl;
94 if ( !
model )
return 0;
105 if ( filename.
empty() ) {
106 cerr <<
"Error: No model filename!" << endl;
113 cout <<
"DEBUG write_model: extension=" << ext << endl;
116 cout <<
"Writing file: " << filename << endl;
135 cerr <<
"Error: File with extension " << ext <<
" not written!" << endl;
187 cout <<
"DEBUG model_add: type=" << new_model->
id << endl;
192 while ( this_model->
next ) this_model = this_model->
next;
193 this_model->
next = new_model;
215 if ( mp ) mp->
next = model_nu;
216 else *
model = model_nu;
240 new_type->
fmod =
"?";
246 cout <<
"DEBUG component_type_add: type=" << new_type->
id << endl;
251 while ( this_type->
next ) this_type = this_type->
next;
252 this_type->
next = new_type;
277 new_comp->
view[2] = 1;
285 cout <<
"DEBUG component_add: id=" << new_comp->
id << endl;
290 while ( this_comp->
next ) this_comp = this_comp->
next;
291 this_comp->
next = new_comp;
321 Blink* this_link = *link;
323 for ( i=0; i<
MAXLINK && comp1->
link[i] && comp1->
link[i] != comp2; i++ ) ;
324 for ( j=0; j<
MAXLINK && comp2->
link[j] && comp2->
link[j] != comp1; j++ ) ;
326 if ( comp1->
link[i] == comp2 && comp2->
link[j] == comp1 ) {
328 cerr <<
"Error: " << comp1->
id <<
" already linked to " << comp2->
id <<
329 "! (" << i <<
" -" << j <<
")" << endl;
334 comp1->
link[i] = comp2;
335 comp2->
link[j] = comp1;
336 comp1->
flag[i] = comp2->
flag[j] = 1;
340 memset(new_link, 0,
sizeof(
Blink));
344 if ( radius < 1e-6 ) radius = (comp1->
radius + comp2->
radius)/4;
346 new_link->
comp[0] = comp1;
347 new_link->
comp[1] = comp2;
349 new_link->
radius = radius;
354 cout <<
"DEBUG link_add: " << comp1->
id <<
" - " << comp2->
id << endl;
359 while ( this_link->
next ) this_link = this_link->
next;
360 this_link->
next = new_link;
368 return link_add(link, comp1, comp2, 0, 0);
385 for ( i=0; i<
MAXLINK && comp->
link[i] && comp->
link[i] != comp2; i++ ) ;
403 if ( mp->
sel ) mp->
fmap = mapfile;
419 cout <<
"DEBUG model_add_type_by_id: id=" <<
id << endl;
444 cout <<
"DEBUG model_add_type_by_filename: filename=" << filename << endl;
448 if ( filename == ct->
fmod )
break;
473 cout <<
"DEBUG model_add_type_by_id_and_filename: id" <<
id <<
" filename=" << filename << endl;
477 if (
id == ct->
id && filename == ct->
fmod )
break;
496 if ( !
model )
return NULL;
501 cout <<
"DEBUG model_get_type: id=" <<
id << endl;
505 if (
id == ct->
id )
break;
521 if ( !
model )
return 0;
528 for ( n=0, mp =
model; mp; mp = mp->
next, n++ ) {
532 for ( comp = mp->
comp; comp; comp = comp->
next )
550 if ( !
model )
return 0;
558 for ( n=0, mp =
model; mp; mp = mp->
next, n++ ) {
559 for ( ct = mp->
type; ct; ct = ct->
next )
560 if ( ct->
id == ot ) ct->
id = nt;
578 cout <<
"DEBUG model_count_component_types: " <<
model->
id << endl;
582 for ( comp = mp->
comp; comp; comp = comp->
next )
597 if ( !
model )
return 0;
599 long nmod(0), ncomp(0), nlink(0);
607 for ( mp =
model; mp; mp = mp->
next, nmod++ ) {
610 for ( comp = mp->
comp; comp; comp = comp->
next, ncomp++ ) {
614 cerr <<
"Component " << comp->
id <<
" has no type assigned" << endl;
618 for ( ct = mp->
type; ct; ct = ct->
next ) {
622 for ( link = mp->
link; link; link = link->
next, nlink++ ) {
640 if ( !
model )
return 0;
646 for ( ncomp=0, mp =
model; mp; mp = mp->
next )
647 for ( comp = mp->
comp; comp; comp = comp->
next, ncomp++ ) ;
662 if ( !
model )
return NULL;
671 mp_new = mp_new->
next;
690 if ( !
model )
return NULL;
701 Blink* link_new = NULL;
720 type_new->
fom = type->
fom;
721 type_new->
sel = type->
sel;
726 if ( !model_new->
comp ) model_new->
comp = comp_new;
733 if ( !model_new->
link ) model_new->
link = link_new;
734 for ( comp =
model->
comp, comp_new = model_new->
comp; comp; comp = comp->
next, comp_new = comp_new->
next ) {
735 if ( link->
comp[0] == comp ) link_new->
comp[0] = comp_new;
736 if ( link->
comp[1] == comp ) link_new->
comp[1] = comp_new;
745 if ( !model_new->
poly ) model_new->
poly = poly_new;
749 for ( comp =
model->
comp, comp_new = model_new->
comp; comp; comp = comp->
next, comp_new = comp_new->
next ) {
750 for ( i=0; poly->
comp[i]; i++ )
751 if ( poly->
comp[i] == comp ) poly_new->
comp[i] = comp_new;
768 toct->
id = fromct->
id;
789 tocomp->
id = fromcomp->
id;
790 tocomp->
loc = fromcomp->
loc;
792 tocomp->
vec = fromcomp->
vec;
793 tocomp->
vel = fromcomp->
vel;
797 tocomp->
fom = fromcomp->
fom;
798 tocomp->
sel = fromcomp->
sel;
810 if ( !comp )
return 0;
814 for ( ; comp; comp = comp->
next, ncomp++ ) ;
827 for ( ; comp; comp = comp->
next )
828 if ( comp->
id ==
id )
return comp;
841 tolink->
comp[0] = fromlink->
comp[0];
842 tolink->
comp[1] = fromlink->
comp[1];
847 tolink->
fom = fromlink->
fom;
848 tolink->
sel = fromlink->
sel;
862 for ( ; link; link = link->
next ) {
863 if ( link->
comp[0] == comp1 )
864 if ( link->
comp[1] == comp2 )
return link;
865 if ( link->
comp[1] == comp1 )
866 if ( link->
comp[0] == comp2 )
return link;
869 cerr <<
"Error: Link not found!" << endl;
900 for ( c = comp; c; ) {
935 for ( ct = type; ct; ) {
955 if ( !
model )
return 0;
964 comp->
link[i] = NULL;
1000 cerr <<
"Error: Component " << comp->
id <<
" is not linked to component " << comp2->
id << endl << endl;
1005 cout <<
"Deleting: " << comp->
id <<
" (" << comp->
sel <<
") " << comp2->
id <<
" (" << comp2->
sel <<
")" << endl;
1007 for ( k=i; k+1<
MAXLINK && comp->
link[k+1]; k++ ) {
1011 comp->
link[k] = NULL;
1014 for ( k=j; k+1<
MAXLINK && comp2->
link[k+1]; k++ ) {
1018 comp2->
link[k] = NULL;
1021 for ( link = plink = *link_list; link; ) {
1022 if ( ( link->
comp[0] == comp && link->
comp[1] == comp2 ) ||
1023 ( link->
comp[1] == comp && link->
comp[0] == comp2 ) ) {
1024 if ( link == plink ) {
1025 *link_list = plink = link->
next;
1058 if ( !comp->
link[i] ) {
1059 cerr <<
"Error: Component " << comp->
id <<
" is not linked to component " << comp2->
id << endl << endl;
1079 for ( p = poly; p; ) {
1102 if ( l->
comp[0] == comp || l->
comp[1] == comp ) {
1132 for ( mp =
model; mp; ) {
1162 if ( !
model )
return 0;
1169 cout <<
"Associating component " << associate_type <<
" with file " << associate_file << endl << endl;
1172 for ( ct = mp->
type; ct; ct = ct->
next )
if ( ct->
sel ) {
1173 if ( ct->
id == associate_type ) {
1174 ct->
fmod = associate_file;
1192 if ( !
model )
return 0;
1199 cout <<
"Associating component " << associate_type <<
" with mass = " << mass << endl << endl;
1202 for ( ct = mp->
type; ct; ct = ct->
next )
if ( ct->
sel ) {
1203 if ( ct->
id == associate_type ) {
1224 if ( !
model )
return 0;
1231 for ( n=0, ct = mp->
type; ct; ct = ct->
next )
if ( ct->
sel ) {
1232 ct->
fmod = filename;
1249 if ( !
model )
return 0;
1270 if ( !
model )
return 0;
1291 if ( !
model )
return 0;
long model_set_fom(Bmodel *model, double fom)
Set the FOM of selected components to a specific value.
Bmodel * read_model_star(Bstring *file_list)
Reads STAR model parameters.
Bmodel * read_model_molecule(Bstring *file_list, Bstring ¶mfile)
Reads molecular model parameters.
long component_count(Bcomponent *comp)
Counts the total number of components.
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
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.
int component_list_kill(Bcomponent *comp)
Deallocates memory for a list of components.
int write_model_bild(Bstring &filename, Bmodel *model)
Writes Chimera BILD model parameters.
Blink * link_add(Blink **link, Bcomponent *comp1, Bcomponent *comp2, double length, double radius)
Adds a component link to a linked list.
Header file for reading and writing atomic model files.
Header file for file checking functions.
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
int link_copy(Blink *fromlink, Blink *tolink)
Copies all elements from one link to another.
Read and write models in XML format.
int model_associate(Bmodel *model, Bstring &associate_type, Bstring &associate_file)
Associates a model file with a component type.
int write_model_molecule(Bstring &filename, Bmodel *model)
Writes molecular model parameters.
Bmodel * model_init(Bstring &id)
Initializes a model structure.
int component_copy(Bcomponent *fromcomp, Bcomponent *tocomp)
Copies all elements from one component to another.
int component_type_copy(Bcomptype *fromct, Bcomptype *toct)
Copies all elements from one component to another.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
int comp_associated_links_kill(Bcomponent *comp, Blink **link)
Deallocates memory for links associated with a component.
Bcomptype * component_type_add(Bcomptype **type, Bstring &id)
Adds a component type to a linked list.
Bcomponent * component_find(Bcomponent *comp, Bstring &id)
Finds a component in a component list.
int model_associate_mass(Bmodel *model, Bstring &associate_type, double mass)
Associates a mass with a component type.
int write_model_star(Bstring &filename, Bmodel *model)
Writes STAR model parameters.
double length(vector< T > v)
long model_set_component_radius(Bmodel *model, double comprad)
Set the display radius for all components to a specific value.
Bmodel * read_model_chimera(Bstring *file_list)
Reads Chimera marker model parameters.
Library routines used for model link processing.
int model_set_type(Bmodel *model, Bstring &set_type)
Reset the component types.
Bmodel * read_model(Bstring &filename)
double distance(const Vector3 &v)
Classes for color objects.
Bcomptype * model_add_type_by_id(Bmodel *model, Bstring &id)
Add a type to a model if the identifier does not exist already.
int link_index(Bcomponent *comp, Bcomponent *comp2)
Returns the index of a linked component.
Bstring command_line_time()
Returns the command line and time in a string.
int link_kill(Blink **link_list, Bcomponent *comp, int i)
Deletes a link.
Header file for reading and writing Chimera marker model parameters.
int comp_type_kill(Bcomptype *type)
Deallocates memory for one component type.
int model_count_component_types(Bmodel *model)
Counts the number of components for each type.
int model_component_count(Bmodel *model)
Counts the total number of components.
int write_model(Bstring &filename, Bmodel *model)
Writes model parameters.
Header file for reading and writing Chimera BILD files.
Bmodel * read_model_bild(Bstring *file_list)
Reads Chimera BILD model parameters.
Header file for general utilities.
Bmodel * read_model_xml(Bstring *file_list)
Reads XML model parameters.
int model_set_comptype_filenames(Bmodel *model, Bstring &filename)
Sets the filenames of all selected component types to the given string.
int write_model_chimera(Bstring &filename, Bmodel *model)
Writes Chimera marker model parameters.
Bcomponent * comp[MAXLINK]
int component_kill(Bcomponent *comp)
Deallocates memory for one component.
Bcomptype * model_get_type(Bmodel *model, Bstring &id)
Return the type corresponding to an identifier.
Bmodel * model_copy(Bmodel *model)
Copies a model.
Bcomptype * model_add_type_by_filename(Bmodel *model, Bstring &filename, int num)
Add a type to a model if the type with the given file name does not exist already.
int model_kill(Bmodel *model)
Deallocates all memory in the list.
int model_check(Bmodel *model, Bstring path)
Checks model properties.
Blink * link_find(Blink *link, Bcomponent *comp1, Bcomponent *comp2)
Finds a link in a link list.
int comp_type_list_kill(Bcomptype *type)
Deallocates memory for a list of component types.
int model_set_map_filenames(Bmodel *model, Bstring &mapfile)
Sets all the map file names of selected models.
long model_set_density(Bmodel *model, double density)
Set the density of selected components to a specific value.
Bstring find_file(Bstring filename, Bstring path, int flag=0)
Searches for a file within or without the given path.
Bmodel * model_list_copy(Bmodel *model)
Copies a model.
Header file for generalized linked list functions.
Header file for reading and writing molecular model parameters.
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
long model_setup_links(Bmodel *model)
Set up the link list for each component.
bool contains(const Bstring &s)
int write_model_xml(Bstring &filename, Bmodel *model)
Writes XML model parameters.
int model_link_list_kill(Bmodel *model)
Deallocates memory for a list of component links.
int write_model_vega(Bstring &filename, Bmodel *model)
Writes Vega model parameters.
int model_change_type(Bmodel *model, Bstring &change_type)
Change a component type name.
Bcomponent * link[MAXLINK]
int poly_list_kill(Bpolygon *poly)
Deallocates memory for a list of polygons.
Header file for reading and writing Vega model parameters.
Bmodel * read_model_vega(Bstring *file_list)
Reads Vega model parameters.
Header file for reading and writing STAR model parameters.