Esempio n. 1
0
 public object Visit(ASTAtom node, object data)
 {
     System.Console.Out.WriteLine(IndentString() + node);
     ++indent;
     data = node.ChildrenAccept(this, data);
     --indent;
     return(data);
 }
Esempio n. 2
0
        public object Visit(ASTAtom node, object data)
        {
            IQueryAtom atom = (IQueryAtom)node.JjtGetChild(0).JjtAccept(this, data);

            for (int i = 1; i < node.JjtGetNumChildren(); i++)
            {
                // if there are ring identifiers
                throw new InvalidOperationException();
            }
            return(atom);
        }
Esempio n. 3
0
        public object Visit(ASTSmarts node, object data)
        {
            SMARTSAtom atom = null;
            SMARTSBond bond = null;

            ASTAtom first = (ASTAtom)node.JjtGetChild(0);

            atom = (SMARTSAtom)first.JjtAccept(this, null);
            if (data != null)
            { // this is a sub smarts
                bond = (SMARTSBond)((object[])data)[1];
                IAtom prev = (SMARTSAtom)((object[])data)[0];
                if (bond == null)
                { // since no bond was specified it could be aromatic or single
                    bond = new AromaticOrSingleQueryBond(builder);
                    bond.SetAtoms(new[] { prev, atom });
                }
                else
                {
                    bond.SetAtoms(new[] { prev, atom });
                }
                if (neighbors.ContainsKey(prev))
                {
                    neighbors[prev].Add(atom);
                }
                query.Bonds.Add(bond);
                bond = null;
            }
            // first ATOM in expression
            query.Atoms.Add(atom);

            if (BitArrays.GetValue(tetrahedral, query.Atoms.Count - 1))
            {
                List <IAtom> localNeighbors = new List <IAtom>(query.GetConnectedAtoms(atom))
                {
                    atom
                };
                neighbors[atom] = localNeighbors;
            }

            // now process the rest of the bonds/atoms
            for (int i = 1; i < node.JjtGetNumChildren(); i++)
            {
                INode child = node.JjtGetChild(i);
                if (child is ASTLowAndBond)
                {
                    bond = (SMARTSBond)child.JjtAccept(this, data);
                }
                else if (child is ASTAtom)
                {
                    SMARTSAtom newAtom = (SMARTSAtom)child.JjtAccept(this, null);
                    if (bond == null)
                    { // since no bond was specified it could be aromatic or single
                        bond = new AromaticOrSingleQueryBond(builder);
                    }
                    bond.SetAtoms(new[] { atom, newAtom });
                    query.Bonds.Add(bond);
                    query.Atoms.Add(newAtom);

                    if (neighbors.ContainsKey(atom))
                    {
                        neighbors[atom].Add(newAtom);
                    }
                    if (BitArrays.GetValue(tetrahedral, query.Atoms.Count - 1))
                    {
                        List <IAtom> localNeighbors = new List <IAtom>(query.GetConnectedAtoms(newAtom))
                        {
                            newAtom
                        };
                        neighbors[newAtom] = localNeighbors;
                    }

                    atom = newAtom;
                    bond = null;
                }
                else if (child is ASTSmarts)
                { // another smarts
                    child.JjtAccept(this, new object[] { atom, bond });
                    bond = null;
                }
                else if (child is ASTRingIdentifier)
                {
                    HandleRingClosure(atom, (ASTRingIdentifier)child);
                }
                else
                {
                    throw new InvalidOperationException("Unhandled node type: " + child.GetType());
                }
            }

            return(query);
        }
Esempio n. 4
0
 public object Visit(ASTAtom node, object data)
 {
     // TODO Auto-generated method stub
     return(null);
 }