original_docstring: Given a mol object, return the 'aromatic' part in that compound.
      Return: aro: a list of smiles of aromatic structures
      idx: a list of atom indexes corresponding to aromatic structures
docstring: Given a mol object, return the 'aromatic' part in that compound.
  Return: aro: a list of smiles of aromatic structures
  idx: a list of atom indexes corresponding to aromatic structures
docstring_tokens: Given a mol object return the ' aromatic ' part in that compound . Return : aro : a list of smiles of aromatic structures idx : a list of atom indexes corresponding to aromatic structures
code: def extractAromatic(mol):
      '''Given a mol object, return the 'aromatic' part in that compound.
      Return: aro: a list of smiles of aromatic structures
      idx: a list of atom indexes corresponding to aromatic structures'''
      def san_check(mole, atom_maps):
          left = set(range(mole.GetNumAtoms())).difference(atom_maps)
          if any([mole.GetAtomWithIdx(i).GetIsAromatic() for i in left]):
              atom_maps.extend([i for i in left if mole.GetAtomWithIdx(i).GetIsAromatic()])
              raise WordNotFoundError
      def NotSingleBond(mole, atom1, atom2):
          bond = mole.GetBondBetweenAtoms(atom1.GetIdx(), atom2.GetIdx())
          if not bond:
              return False
          if bond.GetBondType() == Chem.BondType.SINGLE:
              return False
          return True
      m = mol.__copy__()
      for atom in m.GetAtoms():
          atom.SetAtomMapNum(0)
      aro, new_mol_index = [], []
      amap, bmap=set(), set()
      Chem.Kekulize(m)
      rinfo = m.GetRingInfo()
      n_atom = rinfo.AtomRings()
      for bond in m.GetBonds():
          atom1 = bond.GetBeginAtom()
          atom2 = bond.GetEndAtom()
          order = aromaticmerge(atom1, atom2, bond)
          if order:
              amap.update([atom1.GetIdx(), atom2.GetIdx()])
              bmap.add(bond.GetIdx())
      amap = list(amap)
      bmap = list(bmap)
      rwmol = AtomListToSubMol(m, amap, bmap)
      try:
          san_check(m, amap)
          Chem.SanitizeMol(rwmol)
      except:
          rwmol = AtomListToSubMol(m, amap)
      groups = []
      for mm in Chem.GetMolFrags(rwmol):
          cur_mol = AtomListToSubMol(rwmol, mm)
          std_smiles = standize(Chem.MolToSmiles(cur_mol))
          cur_idx = [amap[i] for i in mm]
          if any([atom.GetIsAromatic() for atom in Chem.MolFromSmiles(std_smiles).GetAtoms()]) and \
              [IsAromatic(mol.GetAtomWithIdx(i)) for i in cur_idx] == [IsAromatic(rwmol.GetAtomWithIdx(i)) for i in mm]:
              updated = set(cur_idx)
          else:
              updated = set([x for group in n_atom for x in group if len(set(cur_idx)&set(group))>2])
          queue = deque(updated)
          while len(queue) > 0:
              extra_atom = queue.popleft()
              EA = m.GetAtomWithIdx(extra_atom)
              if set([aa.GetIdx() for aa in EA.GetNeighbors() if NotSingleBond(m, EA, aa)])<=updated:
                  continue
              arm = set([aa.GetIdx() for aa in EA.GetNeighbors() if NotSingleBond(m, EA, aa)]).difference(updated)
              queue.extend(arm)
              updated.update(arm)
          groups.append(updated)
      merge(groups)
      Chem.SanitizeMol(m)
      Chem.Kekulize(m)
      for group in groups:
          group = list(group)
          cur_mol = AtomListToSubMol(m, group)
         # Chem.SanitizeMol(cur_mol)
          aro_fg, order = standize(cur_mol, Order=True, asMol=True)
          aro.append(standize(aro_fg))
          new_mol_index.append(tuple(group[i] for i in order))
      return aro, new_mol_index
code_tokens: def extractAromatic ( mol ) : def san_check ( mole , atom_maps ) : left = set ( range ( mole . GetNumAtoms ( ) ) ) . difference ( atom_maps ) if any ( [ mole . GetAtomWithIdx ( i ) . GetIsAromatic ( ) for i in left ] ) : atom_maps . extend ( [ i for i in left if mole . GetAtomWithIdx ( i ) . GetIsAromatic ( ) ] ) raise WordNotFoundError def NotSingleBond ( mole , atom1 , atom2 ) : bond = mole . GetBondBetweenAtoms ( atom1 . GetIdx ( ) , atom2 . GetIdx ( ) ) if not bond : return False if bond . GetBondType ( ) == Chem . BondType . SINGLE : return False return True m = mol . __copy__ ( ) for atom in m . GetAtoms ( ) : atom . SetAtomMapNum ( 0 ) aro , new_mol_index = [ ] , [ ] amap , bmap = set ( ) , set ( ) Chem . Kekulize ( m ) rinfo = m . GetRingInfo ( ) n_atom = rinfo . AtomRings ( ) for bond in m . GetBonds ( ) : atom1 = bond . GetBeginAtom ( ) atom2 = bond . GetEndAtom ( ) order = aromaticmerge ( atom1 , atom2 , bond ) if order : amap . update ( [ atom1 . GetIdx ( ) , atom2 . GetIdx ( ) ] ) bmap . add ( bond . GetIdx ( ) ) amap = list ( amap ) bmap = list ( bmap ) rwmol = AtomListToSubMol ( m , amap , bmap ) try : san_check ( m , amap ) Chem . SanitizeMol ( rwmol ) except : rwmol = AtomListToSubMol ( m , amap ) groups = [ ] for mm in Chem . GetMolFrags ( rwmol ) : cur_mol = AtomListToSubMol ( rwmol , mm ) std_smiles = standize ( Chem . MolToSmiles ( cur_mol ) ) cur_idx = [ amap [ i ] for i in mm ] if any ( [ atom . GetIsAromatic ( ) for atom in Chem . MolFromSmiles ( std_smiles ) . GetAtoms ( ) ] ) and [ IsAromatic ( mol . GetAtomWithIdx ( i ) ) for i in cur_idx ] == [ IsAromatic ( rwmol . GetAtomWithIdx ( i ) ) for i in mm ] : updated = set ( cur_idx ) else : updated = set ( [ x for group in n_atom for x in group if len ( set ( cur_idx ) & set ( group ) ) > 2 ] ) queue = deque ( updated ) while len ( queue ) > 0 : extra_atom = queue . popleft ( ) EA = m . GetAtomWithIdx ( extra_atom ) if set ( [ aa . GetIdx ( ) for aa in EA . GetNeighbors ( ) if NotSingleBond ( m , EA , aa ) ] ) <= updated : continue arm = set ( [ aa . GetIdx ( ) for aa in EA . GetNeighbors ( ) if NotSingleBond ( m , EA , aa ) ] ) . difference ( updated ) queue . extend ( arm ) updated . update ( arm ) groups . append ( updated ) merge ( groups ) Chem . SanitizeMol ( m ) Chem . Kekulize ( m ) for group in groups : group = list ( group ) cur_mol = AtomListToSubMol ( m , group ) aro_fg , order = standize ( cur_mol , Order = True , asMol = True ) aro . append ( standize ( aro_fg ) ) new_mol_index . append ( tuple ( group [ i ] for i in order ) ) return aro , new_mol_index
short_docstring: Given a mol object, return the 'aromatic' part in that compound.
short_docstring_tokens: Given a mol object return the ' aromatic ' part in that compound .
comment: '''Given a mol object, return the 'aromatic' part in that compound.
      Return: aro: a list of smiles of aromatic structures
      idx: a list of atom indexes corresponding to aromatic structures'''$SEP$# Chem.SanitizeMol(cur_mol)