Beispiel #1
0
 public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     currentChars = "";
     dictRef      = "";
     //logger.debug("startElement: ", raw);
     //logger.debug("uri: ", uri);
     //logger.debug("local: ", local);
     //logger.debug("raw: ", raw);
     if ("elementType".Equals(local))
     {
         for (int i = 0; i < atts.GetLength(); i++)
         {
             if ("id".Equals(atts.GetFullName(i)))
             {
                 elementType = new PeriodicTableElement(atts.GetValue(i));
             }
         }
     }
     else if ("scalar".Equals(local))
     {
         for (int i = 0; i < atts.GetLength(); i++)
         {
             if ("dictRef".Equals(atts.GetFullName(i)))
             {
                 if ("cas:id".Equals(atts.GetValue(i)))
                 {
                     scalarType = LABEL_CAS;
                 }
                 else if ("cdk:name".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_NAME;
                 }
                 else if ("cdk:atomicNumber".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_ATOMICNUMBER;
                 }
                 else if ("cdk:name".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_NAME;
                 }
                 else if ("cdk:chemicalSerie".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_CHEMICALSERIE;
                 }
                 else if ("cdk:period".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_PERIOD;
                 }
                 else if ("cdk:group".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_GROUP;
                 }
                 else if ("cdk:phase".Equals(atts.GetValue(i)))
                 {
                     scalarType = SCALAR_PHASE;
                 }
             }
         }
     }
 }
Beispiel #2
0
        private IIsotope createIsotopeOfElement(System.String currentElement, SaxAttributesSupport atts)
        {
            IIsotope isotope = builder.newIsotope(currentElement);

            for (int i = 0; i < atts.GetLength(); i++)
            {
                try
                {
                    if ("id".Equals(atts.GetFullName(i)))
                    {
                        isotope.ID = atts.GetValue(i);
                    }
                    else if ("isotopeNumber".Equals(atts.GetFullName(i)))
                    {
                        isotope.MassNumber = System.Int32.Parse(atts.GetValue(i));
                    }
                    else if ("elementType".Equals(atts.GetFullName(i)))
                    {
                        isotope.Symbol = atts.GetValue(i);
                    }
                }
                catch (System.FormatException exception)
                {
                    //logger.error("Value of isotope@", atts.GetFullName(i), " is not as expected.");
                    //logger.debug(exception);
                }
            }
            return(isotope);
        }
Beispiel #3
0
        public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            currentChars = "";
            if ("entry".Equals(local) && !"bibtex:entry".Equals(raw) && !inEntry)
            {
                inEntry = true;
                entry   = new Entry();
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if (atts.GetFullName(i).Equals("id"))
                    {
                        entry.ID = atts.GetValue(i);
                    }
                    else if (atts.GetFullName(i).Equals("term"))
                    {
                        entry.Label = atts.GetValue(i);
                    }
                }
            }
            if ("metadataList".Equals(local) && !inMetadataList)
            {
                inMetadataList = true;
            }

            // if we're in a metadataList then look at individual
            // metadata nodes and check for any whose content refers
            // to QSAR metadata and save that. Currently it does'nt
            // differentiate between descriptorType or descriptorClass.
            // Do we need to differentiate?
            //
            // RG: I think so and so I save a combination of the dictRef attribute
            // and the content attribute
            if ("metadata".Equals(local) && inMetadataList)
            {
                for (int i = 0; i < atts.GetLength() - 1; i += 2)
                {
                    System.String dictRefValue = "";
                    if (atts.GetFullName(i).Equals("dictRef"))
                    {
                        dictRefValue = atts.GetValue(i);
                    }
                    if (atts.GetFullName(i + 1).Equals("content"))
                    {
                        System.String content = atts.GetValue(i + 1);
                        if (content.IndexOf("qsar-descriptors-metadata:") == 0)
                        {
                            entry.setDescriptorMetadata(dictRefValue + "/" + content);
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     currentChars = "";
     dictRef      = "";
     //logger.debug("startElement: ", raw);
     //logger.debug("uri: ", uri);
     //logger.debug("local: ", local);
     //logger.debug("raw: ", raw);
     if ("isotope".Equals(local))
     {
         workingIsotope = createIsotopeOfElement(currentElement, atts);
     }
     else if ("isotopeList".Equals(local))
     {
         currentElement = getElementSymbol(atts);
     }
     else if ("abundance".Equals(local))
     {
         //logger.warn("Disregarding dictRef for now...");
     }
     else if ("scalar".Equals(local))
     {
         for (int i = 0; i < atts.GetLength(); i++)
         {
             if ("dictRef".Equals(atts.GetFullName(i)))
             {
                 dictRef = atts.GetValue(i);
             }
         }
     }
 }
Beispiel #5
0
 private System.String getElementSymbol(SaxAttributesSupport atts)
 {
     for (int i = 0; i < atts.GetLength(); i++)
     {
         if ("id".Equals(atts.GetFullName(i)))
         {
             return(atts.GetValue(i));
         }
     }
     return("");
 }
Beispiel #6
0
        public override void startElement(CMLStack xpath, System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            System.String name = raw;
            isELSYM = false;

            if ("list".Equals(name))
            {
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if (atts.GetFullName(i).Equals("title") && atts.GetValue(i).Equals("sequence"))
                    {
                    }
                    else if (atts.GetFullName(i).Equals("title") && atts.GetValue(i).Equals("connections"))
                    {
                        // assume that Atom's have been read
                        //logger.debug("Assuming that Atom's have been read: storing them");
                        base.storeAtomData();
                        connectionTable = true;
                        //logger.debug("Start Connection Table");
                    }
                    else if (atts.GetFullName(i).Equals("title") && atts.GetValue(i).Equals("connect"))
                    {
                        //logger.debug("New connection");
                        isBond = true;
                    }
                    else if (atts.GetFullName(i).Equals("id") && isBond)
                    {
                        connect_root = atts.GetValue(i);
                    }

                    // ignore other list items at this moment
                }
            }
            else
            {
                base.startElement(xpath, uri, local, raw, atts);
            }
        }
 public override void startElement(CMLStack xpath, System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     System.String name = local;
     if (name.Equals("list"))
     {
         //logger.debug("Oke, JMOLANIMATION seems to be kicked in :)");
         cdo.startObject("Animation");
         base.startElement(xpath, uri, local, raw, atts);
     }
     else if (name.Equals("molecule"))
     {
         cdo.startObject("Frame");
         //logger.debug("New frame being parsed.");
         base.startElement(xpath, uri, local, raw, atts);
     }
     else if (name.Equals("float"))
     {
         bool isEnergy = false;
         //logger.debug("FLOAT found!");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             //logger.debug(" att: ", atts.GetFullName(i), " -> ", atts.GetValue(i));
             if (atts.GetFullName(i).Equals("title") && atts.GetValue(i).Equals("FRAME_ENERGY"))
             {
                 isEnergy = true;
             }
         }
         if (isEnergy)
         {
             // oke, this is the frames energy!
             current = ENERGY;
         }
         else
         {
             base.startElement(xpath, uri, local, raw, atts);
         }
     }
     else
     {
         base.startElement(xpath, uri, local, raw, atts);
     }
 }
Beispiel #8
0
 public override void startElement(CMLStack xpath, System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
 {
     if ("reaction".Equals(local))
     {
         cdo.startObject("Reaction");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             System.String att           = atts.GetFullName(i);
             System.String value_Renamed = atts.GetValue(i);
             if (att.Equals("id"))
             {
                 cdo.setObjectProperty("Reaction", "id", value_Renamed);
             }
         }
     }
     else if ("reactionList".Equals(local))
     {
         cdo.startObject("SetOfReactions");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             System.String att           = atts.GetFullName(i);
             System.String value_Renamed = atts.GetValue(i);
             if (att.Equals("id"))
             {
                 cdo.setObjectProperty("SetOfReactions", "id", value_Renamed);
             }
         }
     }
     else if ("reactant".Equals(local))
     {
         cdo.startObject("Reactant");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             System.String att           = atts.GetFullName(i);
             System.String value_Renamed = atts.GetValue(i);
             if (att.Equals("id"))
             {
                 cdo.setObjectProperty("Reactant", "id", value_Renamed);
             }
         }
     }
     else if ("product".Equals(local))
     {
         cdo.startObject("Product");
         for (int i = 0; i < atts.GetLength(); i++)
         {
             System.String att           = atts.GetFullName(i);
             System.String value_Renamed = atts.GetValue(i);
             if (att.Equals("id"))
             {
                 cdo.setObjectProperty("Product", "id", value_Renamed);
             }
         }
     }
     else if ("molecule".Equals(local))
     {
         // do nothing for now
         base.newMolecule();
     }
     else
     {
         base.startElement(xpath, uri, local, raw, atts);
     }
 }
Beispiel #9
0
        public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            currentChars = "";
            //logger.debug("START Element: ", raw);
            //logger.debug("  uri: ", uri);
            //logger.debug("  local: ", local);
            //logger.debug("  raw: ", raw);

            if ("atomType".Equals(local))
            {
                atomType = builder.newAtomType("R");
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if ("id".Equals(atts.GetFullName(i)))
                    {
                        atomType.AtomTypeName = atts.GetValue(i);
                    }
                }
            }
            else if ("atom".Equals(local))
            {
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if ("elementType".Equals(atts.GetFullName(i)))
                    {
                        atomType.Symbol = atts.GetValue(i);
                    }
                    else if ("formalCharge".Equals(atts.GetFullName(i)))
                    {
                        try
                        {
                            atomType.setFormalCharge(System.Int32.Parse(atts.GetValue(i)));
                        }
                        catch (System.FormatException exception)
                        {
                            //logger.error("Value of <atom> @", atts.GetFullName(i), " is not an integer: ", atts.GetValue(i));
                            //logger.debug(exception);
                        }
                    }
                }
            }
            else if ("scalar".Equals(local))
            {
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if ("dictRef".Equals(atts.GetFullName(i)))
                    {
                        if ("cdk:maxBondOrder".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_MAXBONDORDER;
                        }
                        else if ("cdk:bondOrderSum".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_BONDORDERSUM;
                        }
                        else if ("cdk:hybridization".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_HYBRIDIZATION;
                        }
                        else if ("cdk:formalNeighbourCount".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_FORMALNEIGHBOURCOUNT;
                        }
                        else if ("cdk:valency".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_VALENCY;
                        }
                        else if ("cdk:formalCharge".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_FORMALCHARGE;
                        }
                        else if ("cdk:DA".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_DA;
                        }
                        else if ("cdk:sphericalMatcher".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_SPHERICALMATCHER;
                        }
                        else if ("cdk:ringSize".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_RINGSIZE;
                        }
                        else if ("cdk:ringConstant".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_CHEMICALGROUPCONSTANT;
                        }
                        else if ("cdk:aromaticAtom".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_ISAROMATIC;
                        }
                        else if ("emboss:vdwrad".Equals(atts.GetValue(i)))
                        {
                            scalarType = SCALAR_VANDERWAALSRADIUS;
                        }
                    }
                }
            }
        }
Beispiel #10
0
        public override void startElement(System.String uri, System.String local, System.String raw, SaxAttributesSupport atts)
        {
            xpath.push(local);
            //if (debug)
            //    logger.debug("<", raw, "> -> ", xpath);
            // Detect CML modules, like CRML and CCML
            if (local.StartsWith("reaction"))
            {
                // e.g. reactionList, reaction -> CRML module
                //logger.info("Detected CRML module");
                conv = new CMLReactionModule(conv);
                conventionStack.push(conventionStack.current());
            }
            else
            {
                // assume CML Core

                // Detect conventions
                System.String convName = "";
                for (int i = 0; i < atts.GetLength(); i++)
                {
                    if (atts.GetFullName(i).Equals("convention"))
                    {
                        convName = atts.GetValue(i);
                    }
                }
                if (convName.Length > 0)
                {
                    if (convName.Equals(conventionStack.current()))
                    {
                        //logger.debug("Same convention as parent");
                    }
                    else
                    {
                        //logger.info("New Convention: ", convName);
                        if (convName.Equals("CML"))
                        {
                            /* Don't reset the convention handler to CMLCore,
                             * becuase all handlers should extend this handler,
                             * and use it for any content other then specifically
                             * put into the specific convention */
                        }
                        else if (convName.Equals("PDB"))
                        {
                            conv = new PDBConvention(conv);
                        }
                        else if (convName.Equals("PMP"))
                        {
                            conv = new PMPConvention(conv);
                        }
                        else if (convName.Equals("MDLMol"))
                        {
                            //if (debug)
                            //    logger.debug("MDLMolConvention instantiated...");
                            conv = new MDLMolConvention(conv);
                        }
                        else if (convName.Equals("JMOL-ANIMATION"))
                        {
                            conv = new JMOLANIMATIONConvention(conv);
                        }
                        else if (userConventions.ContainsKey(convName))
                        {
                            //unknown convention. userConvention?
                            ICMLConvention newconv = (ICMLConvention)userConventions[convName];
                            newconv.inherit(conv);
                            conv = newconv;
                        }
                        else
                        {
                            //logger.warn("Detected unknown convention: ", convName);
                        }
                    }
                    conventionStack.push(convName);
                }
                else
                {
                    // no convention set/reset: take convention of parent
                    conventionStack.push(conventionStack.current());
                }
            }
            //if (debug)
            //    logger.debug("ConventionStack: ", conventionStack);
            conv.startElement(xpath, uri, local, raw, atts);
        }