Exemplo n.º 1
0
def _hydrogenize(block, hydro):
    mol = Chem.MolFromMolBlock(block, sanitize=False)
    _call([mol], 'UpdatePropertyCache', strict=False)
    _apply([mol], ct._sssr)
    res = Chem.AddHs(mol, addCoords=True) if hydro else Chem.RemoveHs(
        mol, sanitize=False)
    return MolToMarvin(Chem.MolToMolBlock(res))
Exemplo n.º 2
0
def _clean(mrv, dim=2):
    block = MarvinToMol(mrv)
    mol = Chem.MolFromMolBlock(block)
    if not mol:
        print "No mol for block:\n %s" % block
        return mrv
    AllChem.Compute2DCoords(mol, bondLength=0.8)
    if dim == 3:
        mol = _2D23D(mol, True)
        mol = Chem.RemoveHs(mol)
    return MolToMarvin(Chem.MolToMolBlock(mol))
Exemplo n.º 3
0
def _clean(mrv, dim=2):
    block = MarvinToMol(mrv)
    mol = Chem.MolFromMolBlock(block, sanitize=False)
    _call([mol], 'UpdatePropertyCache', strict=False)
    _apply([mol], ct._sssr)
    if not mol:
        print "No mol for block:\n %s" % block
        return mrv
    AllChem.Compute2DCoords(mol, bondLength=0.8)
    if dim == 3:
        mol = _2D23D(mol, True)
        mol = Chem.RemoveHs(mol)
    return MolToMarvin(Chem.MolToMolBlock(mol))
Exemplo n.º 4
0
def _molExport(structure, **kwargs):
    input_f = kwargs.get('input', None)
    output_f = kwargs.get('output', None)

    if not input_f:
        mol = _autoDetect(str(structure))
    elif input_f == 'mrv':
        mol = Chem.MolFromMolBlock(MarvinToMol(structure), sanitize=False)
    elif input_f == 'smiles':
        mol = Chem.MolFromSmiles(str(structure), sanitize=False)
    elif input_f == 'inchi':
        mol = Chem.MolFromInchi(str(structure))
    else:
        mol = Chem.MolFromMolBlock(structure, sanitize=False)

    _call([mol], 'UpdatePropertyCache', strict=False)
    _apply([mol], ct._sssr)

    if not mol.GetNumConformers() or mol.GetConformer().Is3D():
        AllChem.Compute2DCoords(mol, bondLength=0.8)

    if output_f == 'smiles':
        out_structure = Chem.MolToSmiles(mol)

    elif output_f == 'inchi':
        out_structure = Chem.MolToInchi(mol)

    elif output_f == 'inchikey':
        out_structure = Chem.InchiToInchiKey(Chem.MolToInchi(mol))

    elif output_f == 'mol':
        out_structure = Chem.MolToMolBlock(mol)

    elif output_f == 'sdf':
        out_structure = Chem.MolToMolBlock(mol) + '\n$$$$\n'

    elif output_f == 'mrv':
        out_structure = MolToMarvin(Chem.MolToMolBlock(mol))

    return {
        "structure": out_structure,
        "format": output_f,
        "contentUrl": "",
        "contentBaseUrl": ""
    }
Exemplo n.º 5
0
def _hydrogenize(block, hydro):
    mol = Chem.MolFromMolBlock(block)
    res = Chem.AddHs(mol, addCoords=True) if hydro else Chem.RemoveHs(mol)
    return MolToMarvin(Chem.MolToMolBlock(res))