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

Fix for CNF file reader in GromosTopoObjects.

parent e379e298
......@@ -1990,8 +1990,6 @@ class GromosTopology(GromosTopoObject):
def read_cnf(self, fin, decode=False):
emptyLine = re.compile(r"^\s*$")
atomnames=[atype.name for atype in self.atomtypes]
typenames=[atype._type for atype in self.atomtypes]
gbline=0
for line in fin:
if decode:
......@@ -2048,40 +2046,7 @@ class GromosTopology(GromosTopoObject):
anum = int(cmdLine.split()[3])
self.positions.append([float(x) for x in cmdLine.split()[4:]])
if 'SOLV' == resname.upper():
at = [atmi for atmi, atmt in enumerate(
self.atomtypes) if(aatyp == atmt.name.upper(
).replace('-', '').replace('+', '') and
resname == atmt.residue)]
self.atoms.append(GromosAtom(name=atyp,
atom_type=self.atomtypes[at[0]],
atom_number=anum,
solvent_mol=True,
residue=resname, mol_id=resid))
else:
at = [atmi for atmi, atmt in enumerate(
self.atomtypes) if(aatyp == atmt.name.upper(
).replace('-', '').replace('+', '') and
rresname == atmt.residue.upper(
).replace('-', '').replace('+', '') and
resid == atmt.res_id)]
self.atoms.append(GromosAtom(name=atyp,
atom_type=self.atomtypes[at[0]],
atom_number=anum,
residue=resname, mol_id=resid))
if section == 'VELOCITY':
if self.velocities is None:
self.velocities = []
self.velocities.append([float(x) for x in cmdLine.split()[4:]])
if self.positions is None:
if self.atoms is None:
self.atoms = IndexedList()
resid = int(cmdLine.split()[0])
resname = cmdLine.split()[1]
rresname = resname.upper().replace('-', '').replace('+', '')
atyp = cmdLine.split()[2]
aatyp = atyp.upper().replace('-', '').replace('+', '')
anum = int(cmdLine.split()[3])
if 'SOLV' in resname:
if self.atomtypes:
at = [atmi for atmi, atmt in enumerate(
self.atomtypes) if(aatyp == atmt.name.upper(
).replace('-', '').replace('+', '') and
......@@ -2092,20 +2057,75 @@ class GromosTopology(GromosTopoObject):
solvent_mol=True,
residue=resname, mol_id=resid))
else:
self.atoms.append(GromosAtom(name=atyp,
atom_type=None,
atom_number=anum,
solvent_mol=True,
residue=resname, mol_id=resid))
else:
if self.atomtypes:
at = [atmi for atmi, atmt in enumerate(
self.atomtypes) if(aatyp == atmt.name.upper(
).replace('-', '').replace('+', '') and
rresname == atmt.residue.upper(
).replace('-', '').replace('+', '') and
resid == atmt.res_id)]
#at = [atmi for atmi, atmt in enumerate(
# self.atomtypes) if(atyp == atmt.name and
# resname == atmt.residue and
# resid == atmt.res_id)]
self.atoms.append(GromosAtom(name=atyp,
atom_type=self.atomtypes[at[0]],
atom_number=anum,
residue=resname, mol_id=resid))
else:
self.atoms.append(GromosAtom(name=atyp,
atom_type=None,
atom_number=anum,
residue=resname, mol_id=resid))
if section == 'VELOCITY':
if self.velocities is None:
self.velocities = []
self.velocities.append([float(x) for x in cmdLine.split()[4:]])
if self.positions is None:
if self.atoms is None:
self.atoms = IndexedList()
resid = int(cmdLine.split()[0])
resname = cmdLine.split()[1]
rresname = resname.upper().replace('-', '').replace('+', '')
atyp = cmdLine.split()[2]
aatyp = atyp.upper().replace('-', '').replace('+', '')
anum = int(cmdLine.split()[3])
if 'SOLV' in resname:
if self.atomtypes:
at = [atmi for atmi, atmt in enumerate(
self.atomtypes) if(aatyp == atmt.name.upper(
).replace('-', '').replace('+', '') and
resname == atmt.residue)]
self.atoms.append(GromosAtom(name=atyp,
atom_type=self.atomtypes[at[0]],
atom_number=anum,
solvent_mol=True,
residue=resname, mol_id=resid))
else:
self.atoms.append(GromosAtom(name=atyp,
atom_type=None,
atom_number=anum,
solvent_mol=True,
residue=resname, mol_id=resid))
else:
if self.atomtypes:
at = [atmi for atmi, atmt in enumerate(
self.atomtypes) if(aatyp == atmt.name.upper(
).replace('-', '').replace('+', '') and
rresname == atmt.residue.upper(
).replace('-', '').replace('+', '') and
resid == atmt.res_id)]
self.atoms.append(GromosAtom(name=atyp,
atom_type=self.atomtypes[at[0]],
atom_number=anum,
residue=resname, mol_id=resid))
else:
self.atoms.append(GromosAtom(name=atyp,
atom_type=None,
atom_number=anum,
residue=resname, mol_id=resid))
if section == 'GENBOX':
if gbline == 0:
self.nbounds = int(cmdLine.split()[0])
......
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