SHARE
TWEET

build_a_molecule_ideas

a guest Apr 30th, 2012 136 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Molecule(object):
  2.  
  3.     def __init__(self,name=None,smiles=None):
  4.         self.name = name # molecule name
  5.         self.atomlist = someParserGoesHere(smiles) # list of atoms, perhaps list of atom objects???
  6.         self.structure = someParserGoesHere(smiles) # 'structure' attribute should be a 2D connectivity matrix
  7.         self.functionalgroups = ...
  8.  
  9.     def determineFunctionalGroups(self):
  10.         # Figure out how to get functional groups for visual highlighting.
  11.  
  12.     def mutateMethod(self,mutate_instruction):
  13.         # some function that adds or removes atoms to the molecule
  14.         # based on some defined syntax, e.g. "add Carbon to C7"
  15.  
  16. class Atom(object): # or should it be Atom(Molecule), a subclass
  17.  
  18.     def __init__(self,atomtype=None):
  19.         self.atomtype = atomtype
  20.         # For the variables below I would have some dictionary/function to give these values based on atomtype
  21.         self.mass = massdict['atomtype']
  22.         self.atomicnum = atomicnum...
  23.         self.charge = charge...
  24.         self.numbonds = numbonds... # can be checked to make sure valence is correct
  25.  
  26.     def printAttributes(self):
  27.         print "Atomtype: %s" % self.atomtype
  28.         print "Mass: %f" % self.mass
  29.         # yadda yadda yadda
  30.  
  31. class Bond(Molecule):
  32.     pass
  33.  
  34. class FunctionalGroup(Molecule):
  35.     pass
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top