Beispiel #1
0
def buildConnectivity(mol, makeZMatrix="true", copyConnectivity="false"):
    mb = Utility.getDefaultImplFor(MoleculeBuilder).newInstance() 

    if (copyConnectivity == "false"):
      try: 
        if (makeZMatrix == "false"):
          for i in range(0, len(mol)):
             mb.makeConnectivity(mol[i])
        else:
          for i in range(0, len(mol)):
             mb.makeZMatrix(mol[i])
      except:
        if (makeZMatrix == "false"):
          mb.makeConnectivity(mol)
        else:
          mb.makeZMatrix(mol)
    else:
      try:
        if (makeZMatrix == "false"):
          mb.makeConnectivity(mol[0])
        else:
          mb.makeZMatrix(mol[0])
        
        for i in range(1, len(mol)):
           atms  = mol[0].getAtoms();
           iatms = mol[i].getAtoms();  

           while (atms.hasNext() and iatms.hasNext()):
              iatms.next().setConnectedList(atms.next().getConnectedList())
      except:
        if (makeZMatrix == "false"):
          mb.makeConnectivity(mol)
        else:
          mb.makeZMatrix(mol)
Beispiel #2
0
def readMultiMoleculeFile(file, makeZMatrix="true", copyConnectivity="false"):
    mfr = Utility.getDefaultImplFor(MoleculeFileReaderFactory).newInstance()    
    typ = file[file.index(".")+1:len(file)]
    rdr = mfr.getReader(typ)
    br = openFile(file, "r")

    molList = [] 
    try:
       i = 0

       while 1:
          mol = rdr.readMolecule(br)

          if mol.getNumberOfAtoms() == 0: break

          if ((mol.getTitle()==None) or (mol.getTitle()=="") \
               or (mol.getTitle()=="Untitled") \
               or (mol.getTitle().index("Molecule")==0)): 
            mol.setTitle(Utility.getFileNamesSansExtension(File(file)) + "-" + repr(i))

          molList.append(mol)
          i += 1
    except:
       print "Warning: Could not read the complete file " + file

    br.close()

    buildConnectivity(molList, makeZMatrix, copyConnectivity)

    return molList
Beispiel #3
0
def buildSimpleConnectivity(mol):
    mb = Utility.getDefaultImplFor(MoleculeBuilder).newInstance() 

    try:
      for i in range(0, len(mol)):
         mb.makeSimpleConnectivity(mol)
    except:
      mb.makeSimpleConnectivity(mol)
Beispiel #4
0
def molecule(title):
    mol = Utility.getDefaultImplFor(Molecule).newInstance() 
    mol.setTitle(title)
   
    return mol
Beispiel #5
0
def getDefaultClass(theClass):
    return Utility.getDefaultImplFor(theClass)
Beispiel #6
0
def readMoleculeFile(file):
    mfr = Utility.getDefaultImplFor(MoleculeFileReaderFactory).newInstance()    
    typ = file[file.index(".")+1:len(file)]
    rdr = mfr.getReader(typ)
    
    return rdr.readMoleculeFile(file)