Indigo | Indigo(Python)简介、安装与入门

简介: Indigo | Indigo(Python)简介、安装与入门

Indigo简介

Bingo: 针对Oracle,Microsoft SQL Server和PostgreSQL数据库的化学搜索引擎

Indigo: U具有与.NET,Java和Python绑定的通用化学信息库,以及以下工具:

Legio: 组合化学GUI应用程序

ChemDiff: SDF或SMILES文件的可视化比较

indigo-depict: 分子和反应渲染工具

indigo-cano: Canonical SMILES 生成器

indigo-deco: R-Group反卷积实用程序


Indigo安装

Indigo的Python绑定安装

pip install epam.indigo

Indigo入门

from indigo import *
indigo = Indigo()

获取版本

print ("Indigo version " + indigo.version())

Accessing Neighbor Atoms

for atom in mol.iterateAtoms():
  print ("atom %d: %d neighbors" % (atom.index(), atom.degree()))
  for nei in atom.iterateNeighbors():
    print ("neighbor atom %d is connected by bond %d\n" % (nei.index(), nei.bond().index()))

Accessing R-Groups

for rg in mol.iterateRGroups():
  print ("RGROUP #" + rg.index())
  for frag in rg.iterateRGroupFragments():
     print ("  FRAGMENT #" + rg.index())
     print (frag.molfile())

image.png

Stereochemistry

The following methods of IndigoObject are available for accessing molecule’s stereo configuration:


countStereocenters returns the number of the chiral atoms in a molecule

iterateStereocenters returns an iterator for molecule’s atoms that are stereocenters

countAlleneCenters returns the number of allene-like stereo fragments

iterateAlleneCenters returns an iterator for molecule’s atoms that are centers of allene fragments (the middle ‘C’ in ‘C=C=C’)

bondStereo returns one of the following constants:

Indigo.UP — stereo “up” bond

Indigo.DOWN — stereo “down” bond

Indigo.EITHER — stereo “either” bond

Indigo.CIS — “Cis” double bond

Indigo.TRANS — “Trans” double bond

zero — not a stereo bond of any kind

stereocenterType returns one of the following constants:

Indigo.ABS — “absolute” stereocenter

Indigo.OR — “or” stereocenter

Indigo.AND — “and” stereocenter

Indigo.EITHER — “any” stereocenter

zero — not a stereocenter

invertStereo inverts the stereo configuration of an atom

resetStereo resets the stereo configuration of an atom or a bond

changeStereocenterType(newType) changes current stereocenter type to a specified type

addStereocenter(type, idx1, idx2, idx3, [idx4]) adds new stereocenter build on a atom pyramid with a specified atom indices

clearStereocenters resets the chiral configurations of a molecule’s atoms

clearAlleneCenters resets the chiral configurations of a molecule’s allene-like fragments

clearCisTrans resets the cis-trans configurations of a molecule’s bonds

The following methods are useful for keeping cis-trans stereochemistry intact when converting to/from SMILES:


resetSymmetricCisTrans can be called on a molecule loaded from a Molfile or CML. After this call, the cis-trans configurations remain only on nonsymmetric cis-trans bonds. The method returns the number of bonds that have been reset.

markEitherCisTrans can be called prior to saving a molecule loaded from SMILES to Molfile format. It guarantees that the bonds that have no cis-trans configuration in SMILES will not have a cis-trans configuration in the resulting Molfile.

IndigoObject mol = indigo.loadMolecule("chiral.mol");
print mol.countStereocenters(), "chiral atoms"
for atom in mol.iterateStereocenters():
   print "atom", atom.index(), "-- stereocenter type", atom.stereocenterType()
   atom.invertStereo();
for bond in mol.iterateBonds():
   if bond.bondStereo() != 0:
     print "bond", bond.index(), "-- stereo type", bond.bondStereo()
print mol.smiles()
mol.clearStereocenters()
mol.clearCisTrans()
print mol.smiles()

Reaction Products Enumeration

reaction = indigo.loadQueryReaction("Cl[C:1]([*:3])=O.[OH:2][*:4]>>[*:4][O:2][C:1]([*:3])=O")
monomers_table = indigo.createArray()
monomers_table.arrayAdd(indigo.createArray())
monomers_table.at(0).arrayAdd(indigo.loadMolecule("CC(Cl)=O"))
monomers_table.at(0).arrayAdd(indigo.loadMolecule("OC1CCC(CC1)C(Cl)=O"))
monomers_table.arrayAdd(indigo.createArray())
monomers_table.at(1).arrayAdd(indigo.loadMolecule("O[C@H]1[C@H](O)[C@@H](O)[C@H](O)[C@@H](O)[C@@H]1O"))
output_reactions = indigo.reactionProductEnumerate(reaction, monomers_table)
indigo.setOption("render-comment", "Results")
rxn_array = indigo.createArray();
for elem in output_reactions.iterateArray():
    rxn = elem.clone();
    rxn_array.arrayAdd(rxn)
indigoRenderer.renderGridToFile(rxn_array, None, 2, 'result_rpe.png')


image.png

Reaction-based Molecule Transformations

reaction = indigo.loadQueryReaction("[*+:1][*-:2]>>[*:2]=[*:1]")
molecule = indigo.loadMolecule("[O-][C+]1CCCC1[N+]([O-])=O")
indigo.transform(reaction, molecule)
print(molecule.smiles())

运行结果

O=N(C1CCCC1=O)=O



目录
相关文章
|
2月前
|
程序员 UED Python
Python入门:3.Python的输入和输出格式化
在 Python 编程中,输入与输出是程序与用户交互的核心部分。而输出格式化更是对程序表达能力的极大增强,可以让结果以清晰、美观且易读的方式呈现给用户。本文将深入探讨 Python 的输入与输出操作,特别是如何使用格式化方法来提升代码质量和可读性。
Python入门:3.Python的输入和输出格式化
|
14天前
|
IDE 开发工具 开发者
手把手教你安装PyCharm 2025:开发者的Python IDE配置全流程+避坑指南
本教程详细介绍了PyCharm 2025版本在Windows系统下的安装流程及配置方法,涵盖AI代码补全与智能调试工具链等新功能。内容包括系统要求、安装步骤、首次运行配置(如主题选择与插件安装)、创建首个Python项目,以及常见问题解决方法。此外,还提供了切换中文界面和延伸学习资源的指导,帮助用户快速上手并高效使用PyCharm进行开发。
326 60
|
5天前
|
存储 缓存 文件存储
uv安装python及其依赖的加速方法
国内在使用uv的时候,可能会涉及到装python的速度太慢的问题,为了解决这个问题,可以使用`UV_PYTHON_INSTALL_MIRROR`这个环境变量。除此以外,对于多人协作场景,`UV_CACHE_DIR`也是一个有用的环境变量。本文会介绍这两个变量。
196 9
|
15天前
|
数据采集 数据可视化 大数据
Python入门修炼:开启你在大数据世界的第一个脚本
Python入门修炼:开启你在大数据世界的第一个脚本
54 6
|
13天前
|
数据可视化 流计算 Python
Python创意爱心代码大全:从入门到高级的7种实现方式
本文分享了7种用Python实现爱心效果的方法,从简单的字符画到复杂的3D动画,涵盖多种技术和库。内容包括:基础字符爱心(一行代码实现)、Turtle动态绘图、Matplotlib数学函数绘图、3D旋转爱心、Pygame跳动动画、ASCII艺术终端显示以及Tkinter交互式GUI应用。每种方法各具特色,适合不同技术水平的读者学习和实践,是表达创意与心意的绝佳工具。
196 0
|
2月前
|
开发者 Python
Python入门:8.Python中的函数
### 引言 在编写程序时,函数是一种强大的工具。它们可以将代码逻辑模块化,减少重复代码的编写,并提高程序的可读性和可维护性。无论是初学者还是资深开发者,深入理解函数的使用和设计都是编写高质量代码的基础。本文将从基础概念开始,逐步讲解 Python 中的函数及其高级特性。
Python入门:8.Python中的函数
|
2月前
|
存储 索引 Python
Python入门:6.深入解析Python中的序列
在 Python 中,**序列**是一种有序的数据结构,广泛应用于数据存储、操作和处理。序列的一个显著特点是支持通过**索引**访问数据。常见的序列类型包括字符串(`str`)、列表(`list`)和元组(`tuple`)。这些序列各有特点,既可以存储简单的字符,也可以存储复杂的对象。 为了帮助初学者掌握 Python 中的序列操作,本文将围绕**字符串**、**列表**和**元组**这三种序列类型,详细介绍其定义、常用方法和具体示例。
Python入门:6.深入解析Python中的序列
|
2月前
|
缓存 算法 数据处理
Python入门:9.递归函数和高阶函数
在 Python 编程中,函数是核心组成部分之一。递归函数和高阶函数是 Python 中两个非常重要的特性。递归函数帮助我们以更直观的方式处理重复性问题,而高阶函数通过函数作为参数或返回值,为代码增添了极大的灵活性和优雅性。无论是实现复杂的算法还是处理数据流,这些工具都在开发者的工具箱中扮演着重要角色。本文将从概念入手,逐步带你掌握递归函数、匿名函数(lambda)以及高阶函数的核心要领和应用技巧。
Python入门:9.递归函数和高阶函数
|
2月前
|
存储 SQL 索引
Python入门:7.Pythond的内置容器
Python 提供了强大的内置容器(container)类型,用于存储和操作数据。容器是 Python 数据结构的核心部分,理解它们对于写出高效、可读的代码至关重要。在这篇博客中,我们将详细介绍 Python 的五种主要内置容器:字符串(str)、列表(list)、元组(tuple)、字典(dict)和集合(set)。
Python入门:7.Pythond的内置容器
|
1月前
|
数据采集 人工智能 数据挖掘
Python 编程基础与实战:从入门到精通
本文介绍Python编程语言,涵盖基础语法、进阶特性及实战项目。从变量、数据类型、运算符、控制结构到函数、列表、字典等基础知识,再到列表推导式、生成器、装饰器和面向对象编程等高级特性,逐步深入。同时,通过简单计算器和Web爬虫两个实战项目,帮助读者掌握Python的应用技巧。最后,提供进一步学习资源,助你在Python编程领域不断进步。