Ejemplo n.º 1
0
        public void Save()
        {
            InsertMethParamsVisibility = false;
            NewTabVisibility           = true;

            if (MainWindowViewModel.Instance.typeOfChallenge == "Chemical")
            {
                ChemModel chemModel = new ChemModel(MainWindowViewModel.dataServiceInstance,
                                                    MainWindowViewModel.methParamsInstance,
                                                    MainWindowViewModel.Instance.iconRepository.GetIcons());

                chemModel.MakeExIcons();
                chemModel.MakeCohorts();
                chemModel.MakeCIPs();

                Dictionary <int, DailyReport> report;
                report = chemModel.MakeReport();
                MainWindowViewModel.Instance.ShowReport(report);
            }
            else if (MainWindowViewModel.Instance.typeOfChallenge == "Nuclear")
            {
                NuclearAgent.CalculateNucChallenge(MainWindowViewModel.Instance.iconRepository.GetIcons());

                /*
                 *
                 * Convert NuclearAgent.OutputTable(DataTable) to Dictionary
                 *
                 * */

                //MainWindowViewModel.Instance.ShowReport(GetDict(NuclearAgent.OutputTable));
            }
        }
Ejemplo n.º 2
0
 public override void StartDocument()
 {
     ChemFile       = new ChemFile();
     chemSequence   = new ChemSequence();
     chemModel      = new ChemModel();
     setOfMolecules = new ChemObjectSet <IAtomContainer>();
 }
Ejemplo n.º 3
0
        public void TestCreateNewMolecule_IChemModel()
        {
            var            model = new ChemModel();
            IAtomContainer ac    = ChemModelManipulator.CreateNewMolecule(model);

            Assert.AreEqual(1, model.MoleculeSet.Count);
            Assert.AreEqual(ac, model.MoleculeSet[0]);
        }
Ejemplo n.º 4
0
        public void TestGetAllAtomContainers_IChemModel()
        {
            var filename = "NCDK.Data.MDL.a-pinene.mol";

            Trace.TraceInformation("Testing: " + filename);
            var ins = ResourceLoader.GetAsStream(filename);

            var       reader   = new MDLV2000Reader(ins);
            ChemModel chemFile = (ChemModel)reader.Read((ChemObject) new ChemModel());

            Assert.IsNotNull(chemFile);
            var containersList = ChemModelManipulator.GetAllAtomContainers(chemFile);

            Assert.AreEqual(1, containersList.Count());
        }
Ejemplo n.º 5
0
        public void TestGetAllAtomContainers_IChemModel_WithReactions()
        {
            var filename = "NCDK.Data.MDL.0024.stg02.rxn";

            Trace.TraceInformation("Testing: " + filename);
            var ins = ResourceLoader.GetAsStream(filename);

            MDLRXNV2000Reader reader   = new MDLRXNV2000Reader(ins, ChemObjectReaderMode.Strict);
            ChemModel         chemFile = (ChemModel)reader.Read((ChemObject) new ChemModel());

            Assert.IsNotNull(chemFile);
            var containersList = ChemModelManipulator.GetAllAtomContainers(chemFile);

            Assert.AreEqual(2, containersList.Count());
        }
Ejemplo n.º 6
0
        public void TestRemoveAtomAndConnectedElectronContainers_IChemModel_IAtom()
        {
            IAtomContainer mol1  = new AtomContainer();
            IAtom          atom1 = new Atom("Cl");

            mol1.Atoms.Add(atom1);
            mol1.Atoms.Add(new Atom("Cl"));
            IBond bond1 = new Bond(mol1.Atoms[0], mol1.Atoms[1]);

            mol1.Bonds.Add(bond1);
            IAtomContainer mol2  = new AtomContainer();
            IAtom          atom2 = new Atom("I");

            mol2.Atoms.Add(atom2);
            mol2.Atoms.Add(new Atom("I"));
            IBond bond2 = new Bond(mol2.Atoms[0], mol2.Atoms[1]);

            mol2.Bonds.Add(bond2);
            var molSet = ChemObjectBuilder.Instance.NewAtomContainerSet();

            molSet.Add(mol1);
            IReaction r = new Reaction();

            r.Products.Add(mol2);
            IReactionSet rSet = new ReactionSet
            {
                r
            };
            var model = new ChemModel
            {
                MoleculeSet = molSet,
                ReactionSet = rSet
            };
            IAtom otherAtom = new Atom("Cl");

            Assert.AreEqual(2, ChemModelManipulator.GetBondCount(model));
            Assert.AreEqual(4, ChemModelManipulator.GetAtomCount(model));
            ChemModelManipulator.RemoveAtomAndConnectedElectronContainers(model, otherAtom);
            Assert.AreEqual(2, ChemModelManipulator.GetBondCount(model));
            Assert.AreEqual(4, ChemModelManipulator.GetAtomCount(model));
            ChemModelManipulator.RemoveAtomAndConnectedElectronContainers(model, atom1);
            Assert.AreEqual(1, ChemModelManipulator.GetBondCount(model));
            Assert.AreEqual(3, ChemModelManipulator.GetAtomCount(model));
            ChemModelManipulator.RemoveAtomAndConnectedElectronContainers(model, atom2);
            Assert.AreEqual(0, ChemModelManipulator.GetBondCount(model));
            Assert.AreEqual(2, ChemModelManipulator.GetAtomCount(model));
        }
Ejemplo n.º 7
0
        public void TestMoleculeSet()
        {
            var list = new ChemObjectSet <IAtomContainer>
            {
                new AtomContainer(),
                new AtomContainer()
            };
            var model = new ChemModel {
                MoleculeSet = list
            };

            IChemModel roundTripped = CMLRoundTripTool.RoundTripChemModel(convertor, model);
            var        newList      = roundTripped.MoleculeSet;

            Assert.IsNotNull(newList);
            Assert.AreEqual(2, newList.Count());
            Assert.IsNotNull(newList[0]);
            Assert.IsNotNull(newList[1]);
        }
Ejemplo n.º 8
0
        public void TestChemModel()
        {
            ChemModel  model       = new ChemModel();
            var        moleculeSet = new ChemObjectSet <IAtomContainer>();
            var        mol         = new AtomContainer();
            PseudoAtom atom        = new PseudoAtom("N");

            mol.Atoms.Add(atom);
            moleculeSet.Add(mol);
            model.MoleculeSet = moleculeSet;

            IChemModel roundTrippedModel = CMLRoundTripTool.RoundTripChemModel(convertor, model);

            var roundTrippedMolSet = roundTrippedModel.MoleculeSet;

            Assert.IsNotNull(roundTrippedMolSet);
            Assert.AreEqual(1, roundTrippedMolSet.Count);
            IAtomContainer roundTrippedMolecule = roundTrippedMolSet[0];

            Assert.IsNotNull(roundTrippedMolecule);
            Assert.AreEqual(1, roundTrippedMolecule.Atoms.Count);
        }
Ejemplo n.º 9
0
        public IEnumerable <KeyValuePair <int, DailyReport> > GetChemical([FromBody] Input input)
        {
            ChemModel model = new ChemModel(new DataService(), input.MethParams, input.Icons);

            return(model.MakeReport());
        }
Ejemplo n.º 10
0
 private void createNiceMACiETitle(ChemModel chemModel)
 {
     //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
     chemModel.setProperty(CDKConstants.TITLE, "MACIE " + currentEntry.getProperty(EnzymeName) + "= " + "PDB: " + currentEntry.getProperty(PDBCode) + ", " + "EC: " + currentEntry.getProperty(ECNumber));
 }
Ejemplo n.º 11
0
        /// <summary> Read a Reaction from a file in MACiE RDF format.
        ///
        /// </summary>
        /// <returns>  The Reaction that was read from the MDL file.
        /// </returns>
        private IChemObject readReactions(bool selectEntry)
        {
            ChemSequence entries = new ChemSequence();

            currentEntry = null;
            int entryCounter = 0;

            currentReactionStepSet = null;

            while (input.Peek() != -1)
            {
                //UPGRADE_WARNING: Method 'java.io.LineNumberReader.readLine' was converted to 'System.IO.StreamReader.ReadLine' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
                System.String line = input.ReadLine();
                if (line.StartsWith("$RDFILE"))
                {
                    entries = new ChemSequence();
                }
                else if (line.StartsWith("$DATM"))
                {
                    entries.setProperty(CreationDate, line.Substring(7));
                }
                else if (line.StartsWith("$RIREG"))
                {
                    // new entry, store previous entry if any
                    if (currentEntry != null)
                    {
                        // store previous entry
                        currentEntry.SetOfReactions = currentReactionStepSet;
                        createNiceMACiETitle(currentEntry);
                        entries.addChemModel(currentEntry);
                        fireFrameRead();
                        if (selectEntry && (entryCounter == selectedEntry.SettingValue))
                        {
                            //logger.info("Starting reading wanted frame: ", selectedEntry);
                            return(currentEntry);
                        }
                        else
                        {
                            //logger.debug("Not reading unwanted frame: " + entryCounter);
                        }
                    }
                    currentEntry = new ChemModel();
                    entryCounter++;
                    if (!selectEntry || entryCounter == selectedEntry.SettingValue)
                    {
                        readThisEntry = true;
                    }
                    else
                    {
                        readThisEntry = false;
                    }
                    currentReactionStepSet = new SetOfReactions();
                }
                else if (line.StartsWith("$DTYPE"))
                {
                    System.String[] tuple    = readDtypeDatumTuple(line);
                    System.String   dataType = tuple[0];
                    System.String   datum    = tuple[1];

                    // now some regular expression wizardry
                    Match subLevelMatcher = subLevelDatum.Match(dataType);
                    if (subLevelMatcher.Success)
                    {
                        // sub level field found
                        System.String field       = subLevelMatcher.Groups[2].Value;
                        System.String fieldNumber = subLevelMatcher.Groups[3].Value;
                        System.String subfield    = subLevelMatcher.Groups[4].Value;
                        processSubLevelField(field, fieldNumber, subfield, datum);
                    }
                    else
                    {
                        Match topLevelMatcher = topLevelDatum.Match(dataType);
                        if (topLevelMatcher.Success)
                        {
                            // top level field found
                            System.String field = topLevelMatcher.Groups[2].Value;
                            processTopLevelField(field, datum);
                        }
                        else
                        {
                            //UPGRADE_ISSUE: Method 'java.io.LineNumberReader.getLineNumber' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioLineNumberReadergetLineNumber'"
                            //logger.error("Could not parse datum tuple of type ", dataType, " around line " + input.getLineNumber());
                        }
                    }
                }
                else
                {
                    //UPGRADE_ISSUE: Method 'java.io.LineNumberReader.getLineNumber' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioLineNumberReadergetLineNumber'"
                    //logger.warn("Unrecognized command on line " + input.getLineNumber(), ": ", line);
                }
            }

            if (currentEntry != null)
            {
                createNiceMACiETitle(currentEntry);
                // store last entry
                currentEntry.SetOfReactions = currentReactionStepSet;
                entries.addChemModel(currentEntry);
                fireFrameRead();
            }

            if (selectEntry)
            {
                // apparently selected last one, other already returned
                return(currentEntry);
            }
            return(entries);
        }
Ejemplo n.º 12
0
 private void createNiceMACiETitle(ChemModel chemModel)
 {
     //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
     chemModel.setProperty(CDKConstants.TITLE, "MACIE " + currentEntry.getProperty(EnzymeName) + "= " + "PDB: " + currentEntry.getProperty(PDBCode) + ", " + "EC: " + currentEntry.getProperty(ECNumber));
 }
Ejemplo n.º 13
0
        /// <summary> Read a Reaction from a file in MACiE RDF format.
        /// 
        /// </summary>
        /// <returns>  The Reaction that was read from the MDL file.
        /// </returns>
        private IChemObject readReactions(bool selectEntry)
        {
            ChemSequence entries = new ChemSequence();
            currentEntry = null;
            int entryCounter = 0;
            currentReactionStepSet = null;

            while (input.Peek() != -1)
            {
                //UPGRADE_WARNING: Method 'java.io.LineNumberReader.readLine' was converted to 'System.IO.StreamReader.ReadLine' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
                System.String line = input.ReadLine();
                if (line.StartsWith("$RDFILE"))
                {
                    entries = new ChemSequence();
                }
                else if (line.StartsWith("$DATM"))
                {
                    entries.setProperty(CreationDate, line.Substring(7));
                }
                else if (line.StartsWith("$RIREG"))
                {
                    // new entry, store previous entry if any
                    if (currentEntry != null)
                    {
                        // store previous entry
                        currentEntry.SetOfReactions = currentReactionStepSet;
                        createNiceMACiETitle(currentEntry);
                        entries.addChemModel(currentEntry);
                        fireFrameRead();
                        if (selectEntry && (entryCounter == selectedEntry.SettingValue))
                        {
                            //logger.info("Starting reading wanted frame: ", selectedEntry);
                            return currentEntry;
                        }
                        else
                        {
                            //logger.debug("Not reading unwanted frame: " + entryCounter);
                        }
                    }
                    currentEntry = new ChemModel();
                    entryCounter++;
                    if (!selectEntry || entryCounter == selectedEntry.SettingValue)
                    {
                        readThisEntry = true;
                    }
                    else
                    {
                        readThisEntry = false;
                    }
                    currentReactionStepSet = new SetOfReactions();
                }
                else if (line.StartsWith("$DTYPE"))
                {
                    System.String[] tuple = readDtypeDatumTuple(line);
                    System.String dataType = tuple[0];
                    System.String datum = tuple[1];

                    // now some regular expression wizardry
                    Match subLevelMatcher = subLevelDatum.Match(dataType);
                    if (subLevelMatcher.Success)
                    {
                        // sub level field found
                        System.String field = subLevelMatcher.Groups[2].Value;
                        System.String fieldNumber = subLevelMatcher.Groups[3].Value;
                        System.String subfield = subLevelMatcher.Groups[4].Value;
                        processSubLevelField(field, fieldNumber, subfield, datum);
                    }
                    else
                    {
                        Match topLevelMatcher = topLevelDatum.Match(dataType);
                        if (topLevelMatcher.Success)
                        {
                            // top level field found
                            System.String field = topLevelMatcher.Groups[2].Value;
                            processTopLevelField(field, datum);
                        }
                        else
                        {
                            //UPGRADE_ISSUE: Method 'java.io.LineNumberReader.getLineNumber' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioLineNumberReadergetLineNumber'"
                            //logger.error("Could not parse datum tuple of type ", dataType, " around line " + input.getLineNumber());
                        }
                    }
                }
                else
                {
                    //UPGRADE_ISSUE: Method 'java.io.LineNumberReader.getLineNumber' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaioLineNumberReadergetLineNumber'"
                    //logger.warn("Unrecognized command on line " + input.getLineNumber(), ": ", line);
                }
            }

            if (currentEntry != null)
            {
                createNiceMACiETitle(currentEntry);
                // store last entry
                currentEntry.SetOfReactions = currentReactionStepSet;
                entries.addChemModel(currentEntry);
                fireFrameRead();
            }

            if (selectEntry)
            {
                // apparently selected last one, other already returned
                return currentEntry;
            }
            return entries;
        }