CoordSet.cpp (pymol-v1.8.6.0.tar.bz2) | : | CoordSet.cpp (pymol-v2.1.0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 758 | skipping to change at line 758 | |||
* matrix: 4x4 homogenous transformation matrix from model space to output | * matrix: 4x4 homogenous transformation matrix from model space to output | |||
* space (view matrix * state matrix). Used for ANISOU. | * space (view matrix * state matrix). Used for ANISOU. | |||
*/ | */ | |||
{ | { | |||
char *aType; | char *aType; | |||
AtomName name; | AtomName name; | |||
ResName resn; | ResName resn; | |||
ov_word chain; | ov_word chain; | |||
char formalCharge[4]; | char formalCharge[4]; | |||
int literal = SettingGetGlobal_b(G, cSetting_pdb_literal_names); | ||||
int reformat = SettingGetGlobal_i(G, cSetting_pdb_reformat_names_mode); | ||||
int ignore_pdb_segi = SettingGetGlobal_b(G, cSetting_ignore_pdb_segi); | int ignore_pdb_segi = SettingGetGlobal_b(G, cSetting_ignore_pdb_segi); | |||
WordType x, y, z; | WordType x, y, z; | |||
AtomInfoGetAlignedPDBResidueName(G, ai, resn); | ||||
AtomInfoGetAlignedPDBAtomName(G, ai, resn, name); | ||||
formalCharge[0] = 0; | formalCharge[0] = 0; | |||
sprintf(resn, "%3.4s", LexStr(G, ai->resn)); | ||||
if(SettingGetGlobal_b(G, cSetting_pdb_truncate_residue_name)) { | ||||
resn[3] = 0; /* enforce 3-letter residue name in PDB files */ | ||||
} | ||||
if(SettingGetGlobal_b(G, cSetting_pdb_formal_charges)) { | if(SettingGetGlobal_b(G, cSetting_pdb_formal_charges)) { | |||
if((ai->formalCharge > 0) && (ai->formalCharge < 10)) { | if((ai->formalCharge > 0) && (ai->formalCharge < 10)) { | |||
sprintf(formalCharge, "%d+", ai->formalCharge); | sprintf(formalCharge, "%d+", ai->formalCharge); | |||
} else if((ai->formalCharge < 0) && (ai->formalCharge > -10)) { | } else if((ai->formalCharge < 0) && (ai->formalCharge > -10)) { | |||
sprintf(formalCharge, "%d-", -ai->formalCharge); | sprintf(formalCharge, "%d-", -ai->formalCharge); | |||
} | } | |||
} | } | |||
if(ai->hetatm) | if(ai->hetatm) | |||
aType = sHETATM; | aType = sHETATM; | |||
else | else | |||
aType = sATOM; | aType = sATOM; | |||
char inscode = ai->getInscode(true); | char inscode = ai->getInscode(true); | |||
VLACheck(*charVLA, char, (*c) + 1000); | VLACheck(*charVLA, char, (*c) + 1000); | |||
const char * ai_name = LexStr(G, ai->name); | ||||
auto ai_name_len = strlen(ai_name); | ||||
bool start_column_1 = false; | ||||
UtilNCopy(name, ai_name, 5); | ||||
if(!ai->name) { | ||||
if(!ai->elem[1]) | ||||
sprintf(name, " %s", ai->elem); | ||||
else | ||||
sprintf(name, "%s", ai->elem); | ||||
} else if(!literal) { | ||||
if(ai_name_len < 4) { /* atom name less than length 4 */ | ||||
if(!isdigit(name[0])) { /* doesn't start with a number */ | ||||
if((toupper(ai->elem[0]) == toupper(name[0])) && ((!ai->elem[1]) || /* s | ||||
ymbol len = 1 */ | ||||
(toupper(ai->elem[1]) == toupper(name[1])))) { /* matched l | ||||
en 2 */ | ||||
/* starts with corrent atomic symbol, so */ | ||||
if(!ai->elem[1]) { /* symbol len = 1 */ | ||||
switch (reformat) { | ||||
case 1: /* pdb with internal pdb */ | ||||
case 3: /* pdb with internal iupac */ | ||||
if((ai->elem[0] == 'H') && ai_name_len > 2) { | ||||
AtomInfoGetPDB3LetHydroName(G, resn, ai_name, name); | ||||
break; | ||||
} | ||||
default: /* otherwise, start in column 1 */ | ||||
start_column_1 = true; | ||||
break; | ||||
} | ||||
} | ||||
} else { /* name doesn't start with atomic symbol */ | ||||
/* then just place it in column 1 as usual */ | ||||
start_column_1 = true; | ||||
} | ||||
} else { /* name starts with a number */ | ||||
switch (reformat) { | ||||
case 2: /* make Amber compliant */ | ||||
if((ai->elem[0] == name[1]) && | ||||
((!ai->elem[1]) || (toupper(ai->elem[1]) == toupper(name[2])))) { | ||||
/* rotate the name to place atom symbol in column 0 to comply with A | ||||
mber PDB format */ | ||||
name[3] = name[0]; | ||||
name[0] = ' '; | ||||
} | ||||
break; | ||||
} | ||||
} /* just stick it in column 0 and hope for the be | ||||
st */ | ||||
} else { /* if name is length 4 */ | ||||
if((ai->elem[0] == name[0]) && ((!ai->elem[1]) || /* symbol len = 1 */ | ||||
(toupper(ai->elem[1]) == toupper(name[ | ||||
1])))) { /* matched len 2 */ | ||||
/* name starts with the atomic symbol */ | ||||
if((!ai->elem[1]) && (ai->elem[0])) { /* but if element is one letter. | ||||
.. */ | ||||
switch (reformat) { | ||||
case 1: /* retaining PDB compliance throughout, or */ | ||||
case 3: /* saving as PDB compliant, but use IUPAC within | ||||
PyMOL */ | ||||
if(isdigit(name[3])) { /* and last character is a number */ | ||||
/* rotate the name to place atom symbol in column 1 to comply with | ||||
PDB format */ | ||||
name[0] = ai_name[3]; | ||||
name[1] = ai_name[0]; | ||||
name[2] = ai_name[1]; | ||||
name[3] = ai_name[2]; | ||||
name[4] = 0; | ||||
} | ||||
break; | ||||
} | ||||
} | ||||
} else { /* name does not start with the symbol... */ | ||||
if(reformat == 2) { /* AMBER compliance mode */ | ||||
if(isdigit(name[0])) { | ||||
if((ai->elem[0] == name[1]) && | ||||
((!(ai->elem[1])) || (toupper(ai->elem[1]) == toupper(name[2])))) | ||||
{ | ||||
/* rotate the name to place atom symbol in column 0 to comply with | ||||
Amber PDB format */ | ||||
name[0] = ai_name[1]; | ||||
name[1] = ai_name[2]; | ||||
name[2] = ai_name[3]; | ||||
name[3] = ai_name[0]; | ||||
name[4] = 0; | ||||
} | ||||
} | ||||
} | ||||
} | ||||
} | ||||
} else { /* LITERAL mode: preserve what was in the origin | ||||
al PDB as best PyMOL can | ||||
this should enable people to open and save am | ||||
ber pdb files without issues */ | ||||
if (ai_name_len < 4 && !(ai->elem[1] && /* elem len = 2 */ | ||||
toupper(ai->elem[0]) == toupper(name[0]) && | ||||
toupper(ai->elem[1]) == toupper(name[1]))) { | ||||
start_column_1 = true; | ||||
} | ||||
} | ||||
if (start_column_1) { | ||||
name[0] = ' '; | ||||
UtilNCopy(name + 1, ai_name, 4); | ||||
} | ||||
if(SettingGetGlobal_b(G, cSetting_pdb_retain_ids)) { | if(SettingGetGlobal_b(G, cSetting_pdb_retain_ids)) { | |||
cnt = ai->id - 1; | cnt = ai->id - 1; | |||
} | } | |||
if(cnt > 99998) | if(cnt > 99998) | |||
cnt = 99998; | cnt = 99998; | |||
name[4] = 0; | ||||
if((!pdb_info) || (!pdb_info->is_pqr_file())) { /* relying upon short-circuit */ | if((!pdb_info) || (!pdb_info->is_pqr_file())) { /* relying upon short-circuit */ | |||
short linelen; | short linelen; | |||
sprintf(x, "%8.3f", v[0]); | sprintf(x, "%8.3f", v[0]); | |||
x[8] = 0; | x[8] = 0; | |||
sprintf(y, "%8.3f", v[1]); | sprintf(y, "%8.3f", v[1]); | |||
y[8] = 0; | y[8] = 0; | |||
sprintf(z, "%8.3f", v[2]); | sprintf(z, "%8.3f", v[2]); | |||
z[8] = 0; | z[8] = 0; | |||
linelen = | linelen = | |||
sprintf((*charVLA) + (*c), | sprintf((*charVLA) + (*c), | |||
End of changes. 5 change blocks. | ||||
115 lines changed or deleted | 3 lines changed or added |