⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smilesgenerator.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			{				//Found ring closure between next and a				//logger.debug("found ringclosure in DFTTreeCreation");				ringMarker++;				BrokenBond bond = new BrokenBond(a, next, ringMarker);				if (!brokenBonds.contains(bond))				{					brokenBonds.add(bond);				} else				{					ringMarker--;				}			}		}	}	/**	 *  Parse a branch	 */	private void parseChain(Vector v, StringBuffer buffer, IAtomContainer container, IAtom parent, boolean chiral, boolean[] doubleBondConfiguration, Vector atomsInOrderOfSmiles, boolean useAromaticity)	{		int positionInVector = 0;		IAtom atom;		//logger.debug("in parse chain. Size of tree: " + v.size());		for (int h = 0; h < v.size(); h++)		{			Object o = v.get(h);			if (o instanceof IAtom)			{				atom = (IAtom) o;				if (parent != null)				{					parseBond(buffer, atom, parent, container, useAromaticity);				} else				{					if (chiral && BondTools.isStereo(container, atom))					{						parent = (IAtom) ((Vector) v.get(1)).get(0);					}				}				parseAtom(atom, buffer, container, chiral, doubleBondConfiguration, parent, atomsInOrderOfSmiles, v, useAromaticity);				//logger.debug("in parseChain after parseAtom()");				/*				 *  The principle of making chiral smiles is quite simple, although the code is				 *  pretty uggly. The Atoms connected to the chiral center are put in sorted[] in the				 *  order they have to appear in the smiles. Then the Vector v is rearranged according				 *  to sorted[]				 */				if (chiral && BondTools.isStereo(container, atom) && container.getBond(parent, atom) != null)				{					//logger.debug("in parseChain in isChiral");					IAtom[] sorted = null;					List chiralNeighbours = container.getConnectedAtomsList(atom);					if (BondTools.isTetrahedral(container, atom,false) > 0)					{						sorted = new IAtom[3];					}					if (BondTools.isTetrahedral(container, atom,false) == 1)					{						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_DOWN)						{							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0 && BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom) && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[2] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0 && !BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom) && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[1] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[0] = (IAtom) chiralNeighbours.get(i);									}								}							}						}						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_UP)						{							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0 && BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom) && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[1] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0 && !BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom) && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[2] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[0] = (IAtom) chiralNeighbours.get(i);									}								}							}						}						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_UNDEFINED || container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_NONE)						{							boolean normalBindingIsLeft = false;							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0)									{										if (BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom))										{											normalBindingIsLeft = true;											break;										}									}								}							}							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (normalBindingIsLeft)									{										if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0)										{											sorted[0] = (IAtom) chiralNeighbours.get(i);										}										if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_UP)										{											sorted[2] = (IAtom) chiralNeighbours.get(i);										}										if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN)										{											sorted[1] = (IAtom) chiralNeighbours.get(i);										}									} else									{										if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_UP)										{											sorted[1] = (IAtom) chiralNeighbours.get(i);										}										if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0)										{											sorted[0] = (IAtom) chiralNeighbours.get(i);										}										if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN)										{											sorted[2] = (IAtom) chiralNeighbours.get(i);										}									}								}							}						}					}					if (BondTools.isTetrahedral(container, atom,false) == 2)					{						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_UP)						{							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN && BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom) && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[1] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN && !BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom) && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[2] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[0] = (IAtom) chiralNeighbours.get(i);									}								}							}						}						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_DOWN)						{							double angle1 = 0;							double angle2 = 0;							IAtom atom1 = null;							IAtom atom2 = null;							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										if (angle1 == 0)										{											angle1 = BondTools.giveAngle(atom, parent, (IAtom) chiralNeighbours.get(i));											atom1 = (IAtom) chiralNeighbours.get(i);										} else										{											angle2 = BondTools.giveAngle(atom, parent, (IAtom) chiralNeighbours.get(i));											atom2 = (IAtom) chiralNeighbours.get(i);										}									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[1] = (IAtom) chiralNeighbours.get(i);									}								}							}							if (angle1 < angle2)							{								sorted[0] = atom2;								sorted[2] = atom1;							} else							{								sorted[0] = atom1;								sorted[2] = atom2;							}						}					}					if (BondTools.isTetrahedral(container, atom,false) == 3)					{						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_UP)						{							TreeMap hm = new TreeMap();							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))								{									hm.put(new Double(BondTools.giveAngle(atom, parent, ((IAtom) chiralNeighbours.get(i)))), new Integer(i));								}							}							Object[] ohere = hm.values().toArray();							for (int i = ohere.length - 1; i > -1; i--)							{								sorted[i] = ((IAtom) chiralNeighbours.get(((Integer) ohere[i]).intValue()));							}						}						if (container.getBond(parent, atom).getStereo() == 0)						{							double angle1 = 0;							double angle2 = 0;							IAtom atom1 = null;							IAtom atom2 = null;							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0 && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										if (angle1 == 0)										{											angle1 = BondTools.giveAngle(atom, parent, (IAtom) chiralNeighbours.get(i));											atom1 = (IAtom) chiralNeighbours.get(i);										} else										{											angle2 = BondTools.giveAngle(atom, parent, (IAtom) chiralNeighbours.get(i));											atom2 = (IAtom) chiralNeighbours.get(i);										}									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_UP && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[0] = (IAtom) chiralNeighbours.get(i);									}								}							}							if (angle1 < angle2)							{								sorted[1] = atom2;								sorted[2] = atom1;							} else							{								sorted[1] = atom1;								sorted[2] = atom2;							}						}					}					if (BondTools.isTetrahedral(container, atom,false) == 4)					{						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_DOWN)						{							TreeMap hm = new TreeMap();							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))								{									hm.put(new Double(BondTools.giveAngle(atom, parent, ((IAtom) chiralNeighbours.get(i)))), new Integer(i));								}							}							Object[] ohere = hm.values().toArray();							for (int i = ohere.length - 1; i > -1; i--)							{								sorted[i] = ((IAtom) chiralNeighbours.get(((Integer) ohere[i]).intValue()));							}						}						if (container.getBond(parent, atom).getStereo() == 0)						{							double angle1 = 0;							double angle2 = 0;							IAtom atom1 = null;							IAtom atom2 = null;							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0 && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										if (angle1 == 0)										{											angle1 = BondTools.giveAngle(atom, parent, (IAtom) chiralNeighbours.get(i));											atom1 = (IAtom) chiralNeighbours.get(i);										} else										{											angle2 = BondTools.giveAngle(atom, parent, (IAtom) chiralNeighbours.get(i));											atom2 = (IAtom) chiralNeighbours.get(i);										}									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[2] = (IAtom) chiralNeighbours.get(i);									}								}							}							if (angle1 < angle2)							{								sorted[1] = atom2;								sorted[0] = atom1;							} else							{								sorted[1] = atom1;								sorted[0] = atom2;							}						}					}					if (BondTools.isTetrahedral(container, atom,false) == 5)					{						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_DOWN)						{							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_UP)									{										sorted[0] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0)									{										sorted[2] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN)									{										sorted[1] = (IAtom) chiralNeighbours.get(i);									}								}							}						}						if (container.getBond(parent, atom).getStereo() == CDKConstants.STEREO_BOND_UP)						{							for (int i = 0; i < chiralNeighbours.size(); i++)							{								if (chiralNeighbours.get(i) != parent)								{									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN && BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom) && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[0] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == CDKConstants.STEREO_BOND_DOWN && !BondTools.isLeft(((IAtom) chiralNeighbours.get(i)), parent, atom) && !isBondBroken((IAtom) chiralNeighbours.get(i), atom))									{										sorted[2] = (IAtom) chiralNeighbours.get(i);									}									if (container.getBond((IAtom) chiralNeighbours.get(i), atom).getStereo() == 0)									{										sorted[1] = (IAtom) chiralNeighbours.get(i);									}								}							}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -