예제 #1
0
def present_mol(sdf):
	if not sdf.rstrip().endswith("$$$$"):
		return 0
	try:
		mol = StringIO.StringIO(sdf)
		molec = oasa_bridge.read_molfile(mol, App.paper)
		mol.close()
	except:
		return 0
	if len(molec.atoms)<2:
		return 0
	averagey = sum([atom.y for atom in molec.atoms]) / float(len(molec.atoms))
	for atom in molec.atoms:
		atom.y =  2*averagey - atom.y
	N = 0
	for minimol in molec.get_disconnected_subgraphs():
		N += 1
		App.paper.stack.append(minimol)
		minimol.draw()
		App.paper.add_bindings()
		App.paper.start_new_undo_record()
	return N
예제 #2
0
def present_mol(sdf):
    if not sdf.rstrip().endswith("$$$$"):
        return 0
    try:
        mol = StringIO.StringIO(sdf)
        molec = oasa_bridge.read_molfile(mol, App.paper)
        mol.close()
    except:
        return 0
    if len(molec.atoms) < 2:
        return 0
    averagey = sum([atom.y for atom in molec.atoms]) / float(len(molec.atoms))
    for atom in molec.atoms:
        atom.y = 2 * averagey - atom.y
    N = 0
    for minimol in molec.get_disconnected_subgraphs():
        N += 1
        App.paper.stack.append(minimol)
        minimol.draw()
        App.paper.add_bindings()
        App.paper.start_new_undo_record()
    return N
예제 #3
0
 def get_molecules(self, name):
     file = open(name, 'r')
     mols = oasa_bridge.read_molfile(file, self.paper)
     file.close()
     [invert_coords(mol) for mol in mols]
     return mols
                        label_text=_('Give the name of a molecule to fetch:'),
                        entryfield_labelpos = 'n',
                        buttons=(_('OK'),_('Cancel')))
res = dial.activate()
if res == _('OK'):
    name = dial.get()

    # fetch the molfile

    try:
        from io import StringIO
    except ImportError:
        from StringIO import StringIO

    molcas = get_mol_from_web_molfile(name)
    if molcas:
        mol, cas = molcas
        mol = StringIO(mol)
        molec = oasa_bridge.read_molfile(mol, App.paper)[0]
        mol.close()
        App.paper.stack.append(molec)
        molec.draw()
        if cas:
            t = App.paper.new_text(280, 300, text="CAS: " + cas.strip())
            t.draw()
        App.paper.add_bindings()
        App.paper.start_new_undo_record()
    else:
        App.update_status(_("Sorry, molecule with name %s was not found") % name)

예제 #5
0
파일: molfile.py 프로젝트: sctincman/bkchem
 def get_molecules(self, name):
   with open(name, 'r') as f:
     mols = oasa_bridge.read_molfile(f, self.paper)
   [invert_coords(mol) for mol in mols]
   return mols
예제 #6
0
 def get_molecules(self, name):
     with open(name, 'r') as f:
         mols = oasa_bridge.read_molfile(f, self.paper)
     [invert_coords(mol) for mol in mols]
     return mols