Autodesk / Autodesk/molecular-design-toolkit

Error creating new molecule

Open
#164 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
174
Forks
37
PR merge metrics
No merged PRs in 30d

Description

## Bug report
#### Description
TypeError when copying atoms out of a molecule then creating a new one

#### Steps to reproduce

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

raises

```python
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
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
- Operating system: OS X High Sierra
- `python --version` output: Python 3.5.2 :: Continuum Analytics, Inc.
- `pip show moldesign nbmolviz | grep -B1 Version` output: 0.8.0a2

Contributor guide

Open the contributing guide

Research direction

Start with moldesign/molecules/molecule.py, especially Molecule.__init__, _rebuild_topology, and _assign_residue_indices around the reported line. Run the supplied Python reproduction to inspect the failure. Done means constructing a new Molecule from the copied and appended atoms no longer raises the shown TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.