當前位置: 首頁>>代碼示例>>Python>>正文


Python Chem.MolFromMolFile方法代碼示例

本文整理匯總了Python中rdkit.Chem.MolFromMolFile方法的典型用法代碼示例。如果您正苦於以下問題:Python Chem.MolFromMolFile方法的具體用法?Python Chem.MolFromMolFile怎麽用?Python Chem.MolFromMolFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rdkit.Chem的用法示例。


在下文中一共展示了Chem.MolFromMolFile方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse_molecule_to_smiles

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def parse_molecule_to_smiles(target):
    '''
    Parse a molecular type (smiles, rdkit mol or mol file) into smiles format)
    '''
    try:
        mol = Chem.MolFromSmiles(target)
        if mol:
            #This in order to canonicalize the molecule
            return Chem.MolToSmiles(mol)
    except Exception as e:
        try:
            smiles = Chem.MolToSmiles(target, isomericSmiles = gc.USE_STEREOCHEMISTRY)
            if smiles:
                return smiles
        except Exception as e:
            try:
                mol = Chem.MolFromMolFile(target)
                if mol:
                    return Chem.MolToSmiles(mol, isomericSmiles = gc.USE_STEREOCHEMISTRY)
            except Exception as e:
                MyLogger.print_and_log('Unable to parse target molecule format. Parsing Only available for: Smiles, RDKIT molecule and mol files. Returning "None"', parsing_loc, level = 1)
    return None 
開發者ID:connorcoley,項目名稱:ASKCOS,代碼行數:24,代碼來源:parsing.py

示例2: ReadMolFromMol

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def ReadMolFromMol(self, filename=""):
        """
        #################################################################
        Read a molecule with mol file format.

        Usage:

            res=ReadMolFromMol(filename)

            Input: filename is a file name.

            Output: res is a molecule object.
        #################################################################
        """
        self.mol = Chem.MolFromMolFile(filename)
        return self.mol 
開發者ID:gadsbyfly,項目名稱:PyBioMed,代碼行數:18,代碼來源:Pymolecule.py

示例3: ReadMolFromMol

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def ReadMolFromMol(filename=""):
    """
    #################################################################
    Read a molecule with mol file format.

    Usage:

        res=ReadMolFromMol(filename)

        Input: filename is a file name.

        Output: res is a molecule object.
    #################################################################
    """
    mol = Chem.MolFromMolFile(filename)
    return mol


############################################################################# 
開發者ID:gadsbyfly,項目名稱:PyBioMed,代碼行數:21,代碼來源:Getmol.py

示例4: GetMolFromNCBI

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def GetMolFromNCBI(cid=""):
    """
    Downloading the molecules from http://pubchem.ncbi.nlm.nih.gov/ by cid (cid).
    """
    cid = string.strip(cid)
    localfile = urlopen(
        "http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid="
        + cid
        + "&disopt=SaveSDF"
    )
    temp = localfile.readlines()
    f = file("temp.sdf", "w")
    f.writelines(temp)
    f.close()
    localfile.close()
    m = Chem.MolFromMolFile("temp.sdf")
    os.remove("temp.sdf")
    temp = Chem.MolToSmiles(m, isomericSmiles=True)
    return temp 
開發者ID:gadsbyfly,項目名稱:PyBioMed,代碼行數:21,代碼來源:Getmol.py

示例5: GetMolFromDrugbank

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def GetMolFromDrugbank(dbid=""):
    """
    Downloading the molecules from http://www.drugbank.ca/ by dbid (dbid).
    """
    dbid = string.strip(dbid)

    localfile = urlopen("http://www.drugbank.ca/drugs/" + dbid + ".sdf")
    temp = localfile.readlines()
    f = file("temp.sdf", "w")
    f.writelines(temp)
    f.close()
    localfile.close()
    m = Chem.MolFromMolFile("temp.sdf")
    os.remove("temp.sdf")
    temp = Chem.MolToSmiles(m, isomericSmiles=True)
    return temp 
開發者ID:gadsbyfly,項目名稱:PyBioMed,代碼行數:18,代碼來源:Getmol.py

示例6: loadMolFile

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def loadMolFile(self, filename):
        self.fileName = filename
        mol = Chem.MolFromMolFile(str(self.fileName), sanitize=False, strictParsing=False)
        self.editor.mol = mol
        self.statusBar().showMessage("File opened") 
開發者ID:EBjerrum,項目名稱:rdeditor,代碼行數:7,代碼來源:rdEditor.py

示例7: monomer1_from_molfile

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def monomer1_from_molfile(self, molfile, opt=True, removeHs=False):
        self.monomer1 = Chem.MolFromMolFile(molfile, removeHs=removeHs) 
開發者ID:Mishima-syk,項目名稱:psikit,代碼行數:4,代碼來源:sapt.py

示例8: monomer2_from_molfile

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def monomer2_from_molfile(self, molfile, opt=True, removeHs=False):
        self.monomer2 = Chem.MolFromMolFile(molfile, removeHs=removeHs) 
開發者ID:Mishima-syk,項目名稱:psikit,代碼行數:4,代碼來源:sapt.py

示例9: read_from_molfile

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def read_from_molfile(self, molfile, opt=True, removeHs=False):
        self.mol = Chem.MolFromMolFile(molfile, removeHs=removeHs)
        if opt:
            self.rdkit_optimize() 
開發者ID:Mishima-syk,項目名稱:psikit,代碼行數:6,代碼來源:psikit.py

示例10: ReadMolFromMOL

# 需要導入模塊: from rdkit import Chem [as 別名]
# 或者: from rdkit.Chem import MolFromMolFile [as 別名]
def ReadMolFromMOL(filename=""):
    """
    Read a  molecule by mol file format.

    Usage:

        res=ReadMolFromMOL(filename)

        Input: filename is a file name with path.

        Output: res is a  molecular object.

    """
    mol = Chem.MolFromMolFile(filename)
    return mol 
開發者ID:gadsbyfly,項目名稱:PyBioMed,代碼行數:17,代碼來源:Getmol.py


注:本文中的rdkit.Chem.MolFromMolFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。