本文整理汇总了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