コード例 #1
0
def text_to_mol(text):
    gen = read_cdml(text)
    try:
        mol = gen.next()
    except StopIteration:
        return None
    calculate_coords(mol, bond_length=-1)
    return mol
コード例 #2
0
ファイル: cdml.py プロジェクト: Robot-Will/OASA
def text_to_mol( text):
  gen = read_cdml( text)
  try:
    mol = gen.next()
  except StopIteration:
    return None
  calculate_coords( mol, bond_length=-1)
  return mol
コード例 #3
0
def text_to_mol( text, calc_coords=1, localize_aromatic_bonds=True):
  sm = smiles()
  sm.read_smiles( text)
  mol = sm.structure
  if localize_aromatic_bonds:
    mol.localize_aromatic_bonds()
  for b in mol.bonds:
    b.aromatic = 0
  if calc_coords:
    coords_generator.calculate_coords( mol, bond_length=calc_coords)
  return mol
コード例 #4
0
ファイル: inchi.py プロジェクト: Robot-Will/OASA
def text_to_mol( text, include_hydrogens=True, mark_aromatic_bonds=False, calc_coords=1):
  try:
    inc = inchi()
    inc.read_inchi( text)
    mol = inc.structure
    #mol.add_missing_bond_orders()
    if not include_hydrogens:
      mol.remove_unimportant_hydrogens()
    if calc_coords:
      coords_generator.calculate_coords( mol, bond_length=calc_coords)
    if mark_aromatic_bonds:
      mol.mark_aromatic_bonds()
    return mol
  except oasa_inchi_error:
    raise
  except oasa_not_implemented_error:
    raise
  except:
    raise
コード例 #5
0
ファイル: inchi.py プロジェクト: caiyingchun/OASA
def text_to_mol(text,
                include_hydrogens=True,
                mark_aromatic_bonds=False,
                calc_coords=1):
    try:
        inc = inchi()
        inc.read_inchi(text)
        mol = inc.structure
        #mol.add_missing_bond_orders()
        if not include_hydrogens:
            mol.remove_unimportant_hydrogens()
        if calc_coords:
            coords_generator.calculate_coords(mol, bond_length=calc_coords)
        if mark_aromatic_bonds:
            mol.mark_aromatic_bonds()
        return mol
    except oasa_inchi_error:
        raise
    except oasa_not_implemented_error:
        raise
    except:
        raise
コード例 #6
0
ファイル: tests.py プロジェクト: caiyingchun/OASA
def show_dump():
    from molecule import molecule
    from graph.graph import graph
    imp = molecule()
    imp.read_simple_text_file(file("aaa9.txt", "r"))
    removed = True
    while removed:
        removed = False
        for e in list(imp.edges):
            a1, a2 = e.vertices
            for e2 in list(imp.edges):
                if (e is not e2) and set(e.vertices) == set(e2.vertices):
                    imp.disconnect_edge(e2)
                    removed = True
                    break
            if removed:
                break
    import coords_generator
    for part in imp.get_disconnected_subgraphs():
        if len(part.vertices) > 1:
            coords_generator.calculate_coords(part, force=1)
            coords_generator.show_mol(part)
コード例 #7
0
ファイル: tests.py プロジェクト: Robot-Will/OASA
def show_dump():
    from molecule import molecule
    from graph.graph import graph
    imp = molecule()
    imp.read_simple_text_file( file("aaa9.txt","r"))
    removed = True
    while removed:
        removed = False
        for e in list(imp.edges):
            a1,a2 = e.vertices
            for e2 in list(imp.edges):
                if (e is not e2) and set(e.vertices) == set(e2.vertices):
                    imp.disconnect_edge( e2)
                    removed = True
                    break
            if removed:
                break
    import coords_generator
    for part in imp.get_disconnected_subgraphs():
        if len( part.vertices) > 1:
            coords_generator.calculate_coords( part, force=1)
            coords_generator.show_mol( part)
コード例 #8
0
        all_chunks.append( chunk)
  else:
    for chunk, count in gen_formula_fragments_helper( form):
      if count:
        all_chunks.append(")")
      if chunk:
        all_chunks.extend( reverse_formula( chunk))
      if count:
        all_chunks.append("(")
#
#        if count:
#          all_chunks.append( str(count))

  print all_chunks
  #all_chunks.reverse()
  return all_chunks
  
  
if __name__ == "__main__":
  form = 'CH3(CH2)7'
  #form = 'CH3((CH2)2)2O'

  a = linear_formula( form , start_valency=0, end_valency=1)
  if a.molecule:
    m = a.molecule
    coords_generator.calculate_coords( m)
    coords_generator.show_mol( m)
  else:
    print "nothing"