 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
28 cout <<
"DEBUG read_mol_star: filename=" << filename << endl;
30 long i, n, nmol(0), natom(0), resnum;
45 cout <<
"DEBUG read_mol_star: Number of molecules: " << nmol << endl;
49 cerr <<
"Error: Star to molecule conversion unsuccessful!" << endl;
62 for ( block = star->
block; block; block = block->
next ) {
64 molname = *(item->
data);
69 cout <<
"DEBUG read_mol_star: Molecule " << mol->
id << endl;
72 cout <<
"DEBUG read_mol_star: sequence " << mol->
seq << endl;
79 cout <<
"DEBUG read_mol_star: natom=" << natom << endl;
84 if ( item ) data[0] = item->
data;
86 if ( item ) data[1] = item->
data;
88 if ( item ) data[2] = item->
data;
90 if ( item ) data[3] = item->
data;
92 if ( item ) data[4] = item->
data;
94 if ( item ) data[5] = item->
data;
96 if ( item ) data[6] = item->
data;
98 if ( item ) data[7] = item->
data;
100 if ( item ) data[8] = item->
data;
102 if ( item ) data[9] = item->
data;
104 if ( item ) data[10] = item->
data;
106 if ( item ) data[11] = item->
data;
108 if ( item ) data[12] = item->
data;
112 if ( !res || res->
num != resnum || resname != *data[3] ) {
114 if ( !mol->
res ) mol->
res = res;
118 res->
insert[0] = data[2][0][0];
128 if ( data[4] ) atom->
num = data[4]->
integer();
129 if ( data[5] ) strncpy(atom->
el, data[5]->
c_str(), 2);
131 if ( data[7] ) atom->
coord[0] = data[7]->
real();
132 if ( data[8] ) atom->
coord[1] = data[8]->
real();
133 if ( data[9] ) atom->
coord[2] = data[9]->
real();
135 if ( data[10] ) atom->
q = data[10]->
real();
136 if ( data[11] ) atom->
b = data[11]->
real();
137 if ( data[12] ) atom->
chrg = data[12]->
real();
140 for ( i=0; i<n; ++i )
if ( data[i] ) data[i] = data[i]->
next;
218 if ( molname[0] >
'Z' ) molname[0] =
'A';
223 if ( nmol < 1 ) nmol--;
226 cout <<
"DEBUG read_mol_star: Conversion done for " << nmol <<
" molecules" << endl;
235 if ( !block )
return -1;
237 char string[32] =
"", c;
251 for ( ; res; res=res->
next )
252 for ( atom=res->
atom; atom; atom=atom->
next ) {
254 snprintf(
string, 32, format, atom->
num);
256 snprintf(
string, 32, format, atom->
el);
258 snprintf(
string, 32, format, atom->
type);
260 snprintf(
string, 32, format, res->
type);
262 snprintf(
string, 32, format, res->
num);
265 if ( !c || c==
' ' ) c =
'?';
266 snprintf(
string, 32, format, c);
267 }
else if ( strcmp(tag,
ATOM_X) == 0 )
268 snprintf(
string, 32, format, atom->
coord[0]);
269 else if ( strcmp(tag,
ATOM_Y) == 0 )
270 snprintf(
string, 32, format, atom->
coord[1]);
271 else if ( strcmp(tag,
ATOM_Z) == 0 )
272 snprintf(
string, 32, format, atom->
coord[2]);
274 snprintf(
string, 32, format, atom->
q);
276 snprintf(
string, 32, format, atom->
b);
278 snprintf(
string, 32, format, atom->
chrg);
280 if ( !item->
data ) item->
data = data;
281 if ( item->
maxlen < strlen(
string) ) item->
maxlen = strlen(
string);
285 cout <<
"DEBUG item_put_atom_list: " << tag <<
"=" << *(item->
data) << endl;
292 if ( !block )
return -1;
294 char string[32] =
"";
305 for ( ; res; res=res->
next )
306 for ( atom=res->
atom; atom; atom=atom->
next ) {
308 if ( !item->
data ) item->
data = data;
309 if ( item->
maxlen < strlen(
string) ) item->
maxlen = strlen(
string);
313 cout <<
"DEBUG item_put_chain: " << tag <<
"=" << *(item->
data) << endl;
327 cout <<
"DEBUG write_mol_star: filename=" << filename << endl;
334 long natom(0), nmol(0), loop;
341 for ( mol = molgroup->
mol; mol; mol = mol->
next ) {
344 block->
tag = mol->
id;
347 cout <<
"DEBUG write_mol_star: sequence " << mol->
seq << endl;
357 for ( res = mol->
res; res; res = res->
next )
358 for ( atom = res->
atom; atom; atom = atom->
next ) natom++;
long read_mol_star(Bstring &filename, Bmolgroup *molgroup)
Reads a molecule group from a STAR format file.
int item_index(Bstar_block *block, const char *tag)
Gets the STAR item associated with a tag in a STAR data block.
int item_get_integer(Bstar_block *block, const char *tag)
Gets an integer value associated with a tag in a STAR data block.
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
int loop_set_identifier(Bstar_block *block, int loop, int n,...)
Assigns a loop identification number to items.
Bstar_item * item_find_or_make(Bstar_block *block, const char *tag)
Gets the STAR item associated with a tag in a STAR data block.
int atom_clean_type(Batom *atom, const char *type)
Cleans up the type string and assigns an element code to an atom.
int item_put_atom_list(Bstar_block *block, const char *tag, Bresidue *res, const char *format)
int item_put_integer(Bstar_block *block, const char *tag, int value, const char *format)
Writes a integer into a data item associated with a specific data block and tag in a STAR data base.
Header file for reading reflection files.
int write_star(const char *filename, Bstar *star)
Writes a STAR data base to one or more STAR format files.
long item_get_number_for_block(Bstar_block *block, const char *tag)
Gets the number of values associated with a tag in a STAR data block.
Header file for general utilities.
int read_star(const char *filename, Bstar *star)
Reads paramaters and data into a STAR data base from a list of files.
int item_put_chain(Bstar_block *block, const char *tag, Bresidue *res, char chain)
int kill_star(Bstar *star)
Destroys a STAR data base.
Read and write molecules in STAR format.
Header file for generalized linked list functions.
long item_get_number(Bstar *star, const char *tag)
Gets the number of values associated with a tag in a STAR data base.
Bstar_item * item_find(Bstar_block *block, const char *tag)
Gets the STAR item associated with a tag in a STAR data block.
A header file for STAR format files.
char * item_get_string(Bstar_block *block, const char *tag)
Gets a string value associated with a tag in a STAR data block.
int item_put_string(Bstar_block *block, const char *tag, char *string)
Writes a string into a data item associated with a specific data block and tag in a STAR data base.
Bmolecule * molecule_add(Bmolecule **mol, char *name)
Adds a molecule to a linked list.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
long write_mol_star(Bstring &filename, Bmolgroup *molgroup)
Writes a molecule group to a STAR format file.
Bstar * init_star()
Creates a STAR data base.