本文整理匯總了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
示例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
示例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
#############################################################################
示例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
示例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
示例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")
示例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)
示例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)
示例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()
示例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