Exemplo n.º 1
0
        public static string CircularFpToString(CircularFingerprinter cfp)
        {
            CircularFingerprinter.FP fp = null;

            string s = "fp\thashCode\titeration\tatoms\r\n";

            int fpCount = cfp.getFPCount();

            for (int fpi = 0; fpi < fpCount; fpi++)
            {
                fp = cfp.getFP(fpi);
                s += fpi.ToString() + "\t" + fp.hashCode + "\t" + fp.iteration + "\t(" + string.Join(", ", fp.atoms) + ")\r\n";
            }

            return(s);
        }
Exemplo n.º 2
0
        /// <summary>
        /// BuildTest
        /// </summary>
        public static void BuildTest()
        {
            CircularFingerprinter cfp = null;
            int FpClass = CircularFingerprinter.CLASS_ECFP6; // FP diameter
            int FpLen   = 2048;                              // folded binary fp length

            DefaultChemObjectReader cor;
            IAtomContainer          mol, mol2;

            //string molfile = FileUtil.ReadFile(@"C:\Download\CorpId-12345.mol");
            //java.io.StringReader sr = new java.io.StringReader(molfile);
            //if (Lex.Contains(molfile, "v2000"))
            //  cor = new MDLV2000Reader(sr);
            //else
            //  cor = new MDLV3000Reader(sr);

            //cor.setReaderMode(IChemObjectReader.Mode.RELAXED);

            //ac = (IAtomContainer)cor.read(new AtomContainer());
            //cor.close();

            FpClass = CircularFingerprinter.CLASS_ECFP4;             // debug

            cfp = new CircularFingerprinter(FpClass, FpLen);

            FileReader FileReader = new FileReader(@"C:\Download\CorpId-12345.mol");
            //FileReader FileReader = new FileReader(@"C:\Download\V3000 Mols.sdf");

            IteratingSDFReader rdr = new IteratingSDFReader(FileReader, DefaultChemObjectBuilder.getInstance());

            rdr.setReaderMode(IChemObjectReader.Mode.RELAXED);

            while (rdr.hasNext())
            {
                mol = (IAtomContainer)rdr.next();

                mol = CdkMol.GetLargestMoleculeFragment(mol);

                ICountFingerprint cfp1 = cfp.getCountFingerprint(mol);                 // get hash values and counts for each

                cfp.calculate(mol);
                int fpCount = cfp.getFPCount();
                for (int fpi = 0; fpi < fpCount; fpi++)                 // gets
                {
                    CircularFingerprinter.FP cfp2 = cfp.getFP(fpi);     // gets hash, iteration and lists of atoms (dups appear multiple times)
                }

                IBitFingerprint  bfp = cfp.getBitFingerprint(mol);
                java.util.BitSet bs  = bfp.asBitSet();
                int  bsCard          = bfp.cardinality();
                long bsSize          = bfp.size();
                continue;
            }

            FileReader.close();

            return;


            //java.io.StringReader sr = new java.io.StringReader(molfile);
            //AtomContainer mol = new AtomContainer();

            //mol.addAtom(new Atom("C"));
            //mol.addAtom(new Atom("H"));
            //mol.addAtom(new Atom("H"));
            //mol.addAtom(new Atom("H"));
            //mol.addAtom(new Atom("H"));
            //mol.addBond(new Bond(mol.getAtom(0), mol.getAtom(1)));
            //mol.addBond(new Bond(mol.getAtom(0), mol.getAtom(2)));
            //mol.addBond(new Bond(mol.getAtom(0), mol.getAtom(3)));
            //mol.addBond(new Bond(mol.getAtom(0), mol.getAtom(4)));

            //FileReader FileReader = new FileReader(@"C:\Download\CorpId-12345.mol");
            //MolReader mr = new MolReader(FileReader, DefaultChemObjectBuilder.getInstance());
            //java.io.StringReader sr = new java.io.StringReader(molfile);
            //IMol m = (IMol)mr.next();
            //FileReader.close();
        }