Autodesk / molecular-design-toolkit

Notebook-integrated tools for molecular simulation and visualization
http://moldesign.bionano.autodesk.com
Apache License 2.0
165 stars 37 forks source link

Error creating new molecule #164

Open avirshup opened 7 years ago

avirshup commented 7 years ago

Bug report

Description

TypeError when copying atoms out of a molecule then creating a new one

Steps to reproduce

mol = mdt.from_smiles('[H][H]')
atoms = mol.atoms.copy()
atoms.append(mdt.Atom(1))
newmol = mdt.Molecule(atoms)

raises

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-52663920d8c4> in <module>()
      2 atoms = mol.atoms.copy()
      3 atoms.append(mdt.Atom(1))
----> 4 newmol = mdt.Molecule(atoms)

~/mycode/molecular-design-toolkit/moldesign/molecules/molecule.py in __init__(self, atomcontainer, name, bond_graph, copy_atoms, pdbname, charge, metadata)
   1058         self.chains = Instance(molecule=self)
   1059         self.residues = []
-> 1060         self._rebuild_topology(bond_graph=bond_graph)
   1061 
   1062         if name is not None:

~/mycode/molecular-design-toolkit/moldesign/molecules/molecule.py in _rebuild_topology(self, bond_graph)
    486         self.dim_masses = u.broadcast_to(self.masses, (3, self.num_atoms)).T
    487         self._assign_atom_indices()
--> 488         self._assign_residue_indices()
    489         self._dof = None
    490 

~/mycode/molecular-design-toolkit/moldesign/molecules/molecule.py in _assign_residue_indices(self)
    559 
    560         for atom in self.atoms:
--> 561             if last_pdb_idx is not None and atom.pdbindex <= last_pdb_idx:
    562                 atom.pdbindex = last_pdb_idx + 1
    563                 conflicts.add('atom numbers')

TypeError: unorderable types: NoneType() <= int()

Environment