コード例 #1
0
 public object Visit(ASTReaction node, object data)
 {
     System.Console.Out.WriteLine(IndentString() + node);
     ++indent;
     data = node.ChildrenAccept(this, data);
     --indent;
     return(data);
 }
コード例 #2
0
        public object Visit(ASTReaction node, object data)
        {
            IAtomContainer query = new QueryAtomContainer(builder);

            for (int grpIdx = 0; grpIdx < node.JjtGetNumChildren(); grpIdx++)
            {
                int rollback = query.Atoms.Count;

                ASTGroup group = (ASTGroup)node.JjtGetChild(grpIdx);
                group.JjtAccept(this, query);

                // fill in the roles for newly create atoms
                if (group.Role != ReactionRoles.Any)
                {
                    IQueryAtom   roleQueryAtom = null;
                    ReactionRole?role          = null;

                    // use single instances
                    switch (group.Role)
                    {
                    case ReactionRoles.Reactant:
                        roleQueryAtom = ReactionRoleQueryAtom.RoleReactant;
                        role          = ReactionRole.Reactant;
                        break;

                    case ReactionRoles.Agent:
                        roleQueryAtom = ReactionRoleQueryAtom.RoleAgent;
                        role          = ReactionRole.Agent;
                        break;

                    case ReactionRoles.Product:
                        roleQueryAtom = ReactionRoleQueryAtom.RoleProduct;
                        role          = ReactionRole.Product;
                        break;
                    }

                    if (roleQueryAtom != null)
                    {
                        while (rollback < query.Atoms.Count)
                        {
                            IAtom org = query.Atoms[rollback];
                            IAtom rep = LogicalOperatorAtom.And(roleQueryAtom, (IQueryAtom)org);
                            // ensure AAM is propagated
                            rep.SetProperty(CDKPropertyName.AtomAtomMapping, org.GetProperty <int?>(CDKPropertyName.AtomAtomMapping));
                            rep.SetProperty(CDKPropertyName.ReactionRole, role);
                            AtomContainerManipulator.ReplaceAtomByAtom(query, org, rep);
                            rollback++;
                        }
                    }
                }
            }
            return(query);
        }
コード例 #3
0
ファイル: Smarts2MQLVisitor.cs プロジェクト: ch-hristov/NCDK
 public object Visit(ASTReaction node, object data)
 {
     return(node.JjtGetChild(0).JjtAccept(this, data));
 }