Commit 8fd7c2a5 authored by Berk Onat's avatar Berk Onat

Correction for arrays in topology extraction through ParmEd in MDDataAccess

parent 4434a469
......@@ -422,6 +422,16 @@ def pmdConvertTopoDict(topoStor, topoPMD):
def atompairids(atom1,atom2):
return [atom1[0],atom2[0]]
def getX(x, attr, attr2=None):
try:
if attr2 is not None:
xa = getattr(x, attr)
return getX(xa, attr2)
else:
return getattr(x, attr)
except AttributeError:
return None
structure=None
segmentList = None
......@@ -435,14 +445,15 @@ def pmdConvertTopoDict(topoStor, topoPMD):
# If topo is a PsfFile, the parameter files were not supplied.
# Hence, we can only extract topo info from Psf class in topo.
if isinstance(topoPMD, pmd.charmm.CharmmPsfFile):
structure = [[x.name, x.type, x.residue.name,
x.residue._idx, x.residue.segid,
x.residue.chain, x.altloc,
x.irotat, x.occupancy, x.bfactor, x.mass,
x._charge, x.solvent_radius, x.atomic_number,
x.tree, x.atom_type.name, x.atom_type.epsilon,
x.atom_type.rmin, x.atom_type.epsilon_14,
x.atom_type.rmin_14, x.atom_type.nbfix] for x in topoPMD.atoms]
structure = [[getX(x,'name'), getX(x,'type'), getX(x,'residue','name'),
getX(x,'residue','_idx'), getX(x,'residue','segid'),
getX(x,'residue','chain'), getX(x,'altloc'),
getX(x,'irotat'), getX(x,'occupancy'), getX(x,'bfactor'),
getX(x,'mass'), getX(x,'_charge'), getX(x,'solvent_radius'),
getX(x,'atomic_number'), getX(x,'tree'), getX(x,'atom_type','name'),
getX(x,'atom_type','epsilon'), getX(x,'atom_type','rmin'),
getX(x,'atom_type','epsilon_14'), getX(x,'atom_type','rmin_14'),
getX(x,'atom_type','nbfix')] for x in topoPMD.atoms]
chainList = [a[5] for a in structure]
segmentList = [a[4] for a in structure]
residList = [a[3] for a in structure]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment