Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
title_err = []
struct_obj = block.getObj("struct")
title_string = struct_obj.getValue("title")
title_chunk = int(ceil(len(title_string)/70.0))
for i in range(title_chunk):
line = "TITLE "
if i+1 > 1:
line += " "*(2-len(str(i+1))) + str(i+1)
else:
line += " "
line += title_string[(i*70) : minimum(len(title_string), (i+1)*70)]
try:
title_arr.append(pdb.TITLE(line))
# TODO - what are we catching here?
except:
_LOGGER.error("TITLE: Error parsing line:\n%s", line)
title_err.append("title")
return title_arr, title_err
def get_old_header(pdblist):
"""Get old header from list of PDBs.
Args:
pdblist: list of PDBs
Returns:
Old header as string.
"""
old_header = io.StringIO()
header_types = (pdb.HEADER, pdb.TITLE, pdb.COMPND, pdb.SOURCE, pdb.KEYWDS,
pdb.EXPDTA, pdb.AUTHOR, pdb.REVDAT, pdb.JRNL, pdb.REMARK,
pdb.SPRSDE, pdb.NUMMDL)
for pdb_obj in pdblist:
if not isinstance(pdb_obj, header_types):
break
old_header.write(str(pdb_obj))
old_header.write('\n')
return old_header.getvalue()
str(sc_obj.getValue("fract_transf_vector[2]", 0))
scale3 = ""
scale3 += "SCALE3 "
scale3 += " "*(10 - len(str(sc_obj.getValue("fract_transf_matrix[3][1]", 0)))) + \
str(sc_obj.getValue("fract_transf_matrix[3][1]", 0))
scale3 += " "*(10 - len(str(sc_obj.getValue("fract_transf_matrix[3][2]", 0)))) + \
str(sc_obj.getValue("fract_transf_matrix[3][2]", 0))
scale3 += " "*(10 - len(str(sc_obj.getValue("fract_transf_matrix[3][3]", 0)))) + \
str(sc_obj.getValue("fract_transf_matrix[3][3]", 0))
scale3 += " "
scale3 += " "*(10 - len(str(sc_obj.getValue("fract_transf_vector[3]", 0)))) + \
str(sc_obj.getValue("fract_transf_vector[3]", 0))
try:
sc_arr.append(pdb.SCALE1(scale1))
# TODO - what are we catching here?
except:
_LOGGER.error("cif.scalen: Error parsing line:\n%s", scale1)
sc_err.append("SCALE1")
try:
sc_arr.append(pdb.SCALE2(scale2))
# TODO - what are we catching here?
except:
_LOGGER.error("cif.scalen: Error parsing line:\n%s", scale2)
sc_err.append("SCALE2")
try:
sc_arr.append(pdb.SCALE3(scale3))
# TODO - what are we catching here?
except:
str(sc_obj.getValue("fract_transf_matrix[3][2]", 0))
scale3 += " "*(10 - len(str(sc_obj.getValue("fract_transf_matrix[3][3]", 0)))) + \
str(sc_obj.getValue("fract_transf_matrix[3][3]", 0))
scale3 += " "
scale3 += " "*(10 - len(str(sc_obj.getValue("fract_transf_vector[3]", 0)))) + \
str(sc_obj.getValue("fract_transf_vector[3]", 0))
try:
sc_arr.append(pdb.SCALE1(scale1))
# TODO - what are we catching here?
except:
_LOGGER.error("cif.scalen: Error parsing line:\n%s", scale1)
sc_err.append("SCALE1")
try:
sc_arr.append(pdb.SCALE2(scale2))
# TODO - what are we catching here?
except:
_LOGGER.error("cif.scalen: Error parsing line:\n%s", scale2)
sc_err.append("SCALE2")
try:
sc_arr.append(pdb.SCALE3(scale3))
# TODO - what are we catching here?
except:
_LOGGER.error("cif.scalen: Error parsing line:\n%s", scale3)
sc_err.append("SCALE3")
return sc_arr, sc_err
"""
sample_atom = atoms[-1]
self.atoms = []
self.name = sample_atom.res_name
self.chain_id = sample_atom.chain_id
self.res_seq = sample_atom.res_seq
self.ins_code = sample_atom.ins_code
self.map = {}
self.naname = None
self.reference = None
self.is_n_term = None
self.is_c_term = None
atomclass = ""
for atom in atoms:
if isinstance(atom, pdb.ATOM):
atomclass = "ATOM"
elif isinstance(atom, pdb.HETATM):
atomclass = "HETATM"
atom = structures.Atom(atom, atomclass, self)
atomname = atom.name
if atomname not in self.map:
self.add_atom(atom)
else: # Don't add duplicate atom
oldatom = self.get_atom(atomname)
oldatom.alt_loc = ""
if self.name == "HOH":
self.name = "WAT"
for atom in self.atoms:
atom.res_name = "WAT"
line += " "*(6 - len(str(atoms.getValue("occupancy", i)))) + \
str(atoms.getValue("occupancy", i))
# 61 - 66 TEMP FACTOR
line += " "*(6 - len(str(atoms.getValue("B_iso_or_equiv", i)))) + \
str(atoms.getValue("B_iso_or_equiv", i))
# 67 - 76
line += " "*(10)
# 77 - 78 ELEMENT SYMBOL
line += " "*(2 - len(atoms.getValue("type_symbol", i))) + \
atoms.getValue("type_symbol", i)
# 79 - 80 CHARGE OF ATOM
if atoms.getValue("pdbx_formal_charge", i) == "?":
line += " "*2
else:
atoms.getValue("pdbx_formal_charge", i)
pdb_arr.append(pdb.ATOM(line))
# TODO - what are we catching here?
except:
_LOGGER.error("atom_site: Error reading line: #%s#\n", line)
elif atoms.getValue("group_PDB", i) == "HETATM":
try:
line = ""
# 1 - 6 RECORD NAME (HETATM)
line += atoms.getValue("group_PDB", i) + \
""*(6 - len(atoms.getValue("group_PDB", i)))
# 7 - 11 ATOM SERIAL
line += " "*(5 - len(str(atoms.getValue("id", i)))) + \
str(atoms.getValue("id", i))
# 12 - 13
line += " "
# 14 - 16 ATOM NAME
ParseRadiiDict = {"C": 1.70,
"N": 1.50,
"O": 1.40,
"S": 1.85,
"H": 1.00,
"Br":2.50,
"F": 1.20,
"P": 1.90,
"Cl": 1.75}
#Add lower case keys to more lenient matching.
ParseRadiiDictLower = dict((key.lower(), value) for key, value in ParseRadiiDict.items())
ParseRadiiDict.update(ParseRadiiDictLower)
class ligand_charge_handler(pdb.Mol2Molecule):
"""Make sure that we are up to date with respect to the charge calculation"""
def make_up2date(self,residue):
#
# Check if the structure of the ligand is
# identical to the one we have
#
if not getattr(self,'ligand_props',None):
self.recalc_charges(residue)
# qqqgesges = 0.0
# for aa in residue.atoms:
# #print "newly_calced %s %1.4f " %(aa.name, aa.charge)
# qqqgesges = qqqgesges + aa.charge
#print "-------------------------------"
#print "newly_calced - net charge %1.4f" %(qqqgesges)
#print
self.atoms = []
self.name = sample_atom.res_name
self.chain_id = sample_atom.chain_id
self.res_seq = sample_atom.res_seq
self.ins_code = sample_atom.ins_code
self.map = {}
self.naname = None
self.reference = None
self.is_n_term = None
self.is_c_term = None
atomclass = ""
for atom in atoms:
if isinstance(atom, pdb.ATOM):
atomclass = "ATOM"
elif isinstance(atom, pdb.HETATM):
atomclass = "HETATM"
atom = structures.Atom(atom, atomclass, self)
atomname = atom.name
if atomname not in self.map:
self.add_atom(atom)
else: # Don't add duplicate atom
oldatom = self.get_atom(atomname)
oldatom.alt_loc = ""
if self.name == "HOH":
self.name = "WAT"
for atom in self.atoms:
atom.res_name = "WAT"
if chain_id not in chain_dict:
my_chain = struct.Chain(chain_id)
chain_dict[chain_id] = my_chain
if res_seq != previous_atom.res_seq or \
ins_code != previous_atom.ins_code or \
chain_id != previous_atom.chain_id:
my_residue = self.create_residue(residue, previous_atom.res_name)
chain_dict[previous_atom.chain_id].add_residue(my_residue)
residue = []
residue.append(record)
previous_atom = record
elif isinstance(record, pdb.END):
my_residue = self.create_residue(residue, previous_atom.res_name)
chain_dict[previous_atom.chain_id].add_residue(my_residue)
residue = []
elif isinstance(record, pdb.MODEL):
num_models += 1
if residue == []:
continue
if num_models > 1:
my_residue = self.create_residue(residue,
previous_atom.res_name)
chain_dict[previous_atom.chain_id].add_residue(my_residue)
break
elif isinstance(record, pdb.TER):
count += 1