public bool ContainsAllBitsOf(HasseFingerprint F)
        {
            BitArray fp2 = ((HasseFingerprint)F).fp;
            //todo: think is this good choice:
            // for now think F is null nad has no bits then all fp "contains null"
            // if (fp2 == null) return true;

            for (int i = 0; i < fp.Count; i++)
            {
                if (fp2[i] == true)
                {
                    if (fp[i] != true) return false;
                }
            }

            /*
            BitArray this_clone = new BitArray(fp);
            this_clone.Not(); //zeroes become ones
            this_clone.And(fp2); // a one at any position results in false
            foreach (bool bit in this_clone )
                {
                    if (bit==true) return false;
                }
            */

            return true;
        }
Example #2
0
        public bool ContainsAllBitsOf(HasseFingerprint F)
        {
            BitArray fp2 = ((HasseFingerprint)F).fp;

            //todo: think is this good choice:
            // for now think F is null nad has no bits then all fp "contains null"
            // if (fp2 == null) return true;


            for (int i = 0; i < fp.Count; i++)
            {
                if (fp2[i] == true)
                {
                    if (fp[i] != true)
                    {
                        return(false);
                    }
                }
            }


            /*
             * BitArray this_clone = new BitArray(fp);
             * this_clone.Not(); //zeroes become ones
             * this_clone.And(fp2); // a one at any position results in false
             * foreach (bool bit in this_clone )
             *  {
             *      if (bit==true) return false;
             *  }
             */

            return(true);
        }
        public FingerprintChemHasseNode(string StrMolecule, HasseNodeTypes ElementType, string debugInfo)
            : base(ElementType, debugInfo)
        {
            ChemObject = new IndigoChemistry();
            if (ElementType == HasseNodeTypes.ROOT)
            {
                this.keystring = "0";
            }
            else if (Convert.ToBoolean(ElementType &  HasseNodeTypes.FRAGMENT)) // is fragment
            {
                //   molecule = null;
                hFingerprint = ChemObject.GetEmptyHasseFingerPrint();
                hFingerprint.FromHex(StrMolecule);
                base.size = hFingerprint.bitCount;
                this.keystring = StrMolecule;
                return;
            }

            else
            {
                ChemObject.InitMolecule(StrMolecule);
                this.keystring = ChemObject.keystr;
                _isvalid = ChemObject.ChemistryIsValid;
                hFingerprint = ChemObject.GetHasseFingerPrint();
                base.size = hFingerprint.bitCount;
            }
        }
Example #4
0
        public FingerprintChemHasseNode(string StrMolecule, HasseNodeTypes ElementType, string debugInfo)
            : base(ElementType, debugInfo)
        {
            ChemObject = new IndigoChemistry();
            if (ElementType == HasseNodeTypes.ROOT)
            {
                this.keystring = "0";
            }
            else if (Convert.ToBoolean(ElementType & HasseNodeTypes.FRAGMENT))  // is fragment
            {
                //   molecule = null;
                hFingerprint = ChemObject.GetEmptyHasseFingerPrint();
                hFingerprint.FromHex(StrMolecule);
                base.size      = hFingerprint.bitCount;
                this.keystring = StrMolecule;
                return;
            }

            else
            {
                ChemObject.InitMolecule(StrMolecule);
                this.keystring = ChemObject.keystr;
                _isvalid       = ChemObject.ChemistryIsValid;
                hFingerprint   = ChemObject.GetHasseFingerPrint();
                base.size      = hFingerprint.bitCount;
            }
        }
Example #5
0
        public override bool GetMaxCommonFragments(
            HasseNode Node1, HasseNode Node2,
            bool dbg, HasseFragmentInsertionQueue NewFragmentList,
            int MinimumOverlap)
        {
            string           debugInfo = "";
            HasseFingerprint fp1       = ((FingerprintChemHasseNode)Node1).hFingerprint;
            HasseFingerprint fp1_clone = fp1.CloneHasseFingerprint();
            HasseFingerprint fp2       = ((FingerprintChemHasseNode)Node2).hFingerprint;

            fp1_clone.AndBits(fp2);
            if (fp1_clone.bitCount >= MinimumOverlap)
            {
                string strMCS = fp1_clone.ToHex();

                HasseFingerprint test = new HasseFingerprint();
                test.FromHex(strMCS);

                NewFragmentList.Add(
                    new HasseNode[1] {
                    this
                },                                    // this is lower than new frag
                    new HasseNode[2] {
                    Node1, Node2
                },                                                                                               // those are higher than new frag
                    strMCS,                                                                                      // string to use for new node creation later
                    debugInfo, HasseNode.HasseNodeTypes.FRAGMENT | HasseNode.HasseNodeTypes.MAX_COMMON_FRAGMENT, // type of frag
                    null                                                                                         // this new frag is not associated with a single edge
                    );
                return(true);
            }
            return(false);
        }
 public HasseFingerprint CloneHasseFingerprint()
 {
     BitArray bits = new BitArray(fp); //copies values
     HasseFingerprint chp = new HasseFingerprint();
     chp.fp = bits;
     chp.bitCount = this.bitCount;
     return chp;
 }
Example #7
0
        public HasseFingerprint CloneHasseFingerprint()
        {
            BitArray         bits = new BitArray(fp); //copies values
            HasseFingerprint chp  = new HasseFingerprint();

            chp.fp       = bits;
            chp.bitCount = this.bitCount;
            return(chp);
        }
Example #8
0
        public void Minus(HasseFingerprint FP)
        {
            // do this AND (NOT that)
            BitArray fpx = new BitArray(FP.fp);

            fpx.Not();
            fp.And(fpx);
            this.bitCount = this.CountBits();
        }
        public void AddBitsOf(HasseFingerprint F)
        {
            BitArray fp2 = ((HasseFingerprint)F).fp;

            if (fp == null)
            {
                fp = new System.Collections.BitArray(fp2);
            }
            else
            {
                fp.Or(fp2);
            }
            this.bitCount = this.CountBits();
        }
Example #10
0
 public ChemHasseNode(IndigoChemistry mol, HasseNodeTypes ElementType, string debugInfo)
     : base(ElementType, debugInfo)
 {
     if (ElementType == HasseNodeTypes.ROOT)
     {
         //   molecule = null;
         this.keystring = "{}";
         return;
     }
     ChemObject     = mol;
     this.keystring = ChemObject.keystr;
     _isvalid       = ChemObject.ChemistryIsValid;
     base.size      = ChemObject.heavyAtomCount;
     hFingerprint   = ChemObject.GetHasseFingerPrint();
 }
Example #11
0
        public bool IsLargerThan(HasseFingerprint F)
        {
            //       if (HasAllBits == true) System.Diagnostics.Debugger.Break();
            if (this.bitCount <= F.bitCount)
            {
                return(false);                             // this must be larger
            }
            bool HasAllBits = ContainsAllBitsOf(F);

            if (HasAllBits)
            {
                return(true);
            }
            return(false);
        }
Example #12
0
        public void AddBitsOf(HasseFingerprint F)
        {
            BitArray fp2 = ((HasseFingerprint)F).fp;


            if (fp == null)
            {
                fp = new System.Collections.BitArray(fp2);
            }
            else
            {
                fp.Or(fp2);
            }
            this.bitCount = this.CountBits();
        }
 public FingerprintChemHasseNode(IndigoChemistry mol, HasseNodeTypes ElementType, string debugInfo)
     : base(ElementType, debugInfo)
 {
     if (ElementType == HasseNodeTypes.ROOT)
     {
         //   molecule = null;
         this.keystring = "";
         return;
     }
     ChemObject = mol;
     this.keystring = ChemObject.keystr;
     _isvalid = ChemObject.ChemistryIsValid;
     base.size = ChemObject.heavyAtomCount;
     hFingerprint = ChemObject.GetHasseFingerPrint();
 }
Example #14
0
 public ChemHasseNode(string StrMolecule, HasseNodeTypes ElementType,  string debugInfo)
     : base(ElementType,  debugInfo)
 {
     ChemObject = new IndigoChemistry();
     if (ElementType == HasseNodeTypes.ROOT)
     {
         this.keystring  = "{}";
     }
     else
     {
         ChemObject.InitMolecule(StrMolecule);
         this.keystring = ChemObject.keystr;
         _isvalid = ChemObject.ChemistryIsValid;
         base.size = ChemObject.heavyAtomCount;
         hFingerprint = ChemObject.GetHasseFingerPrint();
     }
 }
Example #15
0
 public ChemHasseNode(string StrMolecule, HasseNodeTypes ElementType, string debugInfo)
     : base(ElementType, debugInfo)
 {
     ChemObject = new IndigoChemistry();
     if (ElementType == HasseNodeTypes.ROOT)
     {
         this.keystring = "{}";
     }
     else
     {
         ChemObject.InitMolecule(StrMolecule);
         this.keystring = ChemObject.keystr;
         _isvalid       = ChemObject.ChemistryIsValid;
         base.size      = ChemObject.heavyAtomCount;
         hFingerprint   = ChemObject.GetHasseFingerPrint();
     }
 }
Example #16
0
        public override string[] GetDifferenceString(HasseNode LargerNode)
        {
            if (this.NodeType == HasseNodeTypes.ROOT)
            {
                return(new string[] { });
            }
            else
            {
                string           buf;
                HasseFingerprint fp      = this.hFingerprint;
                HasseFingerprint fpclone = fp.CloneHasseFingerprint();
                fpclone.Minus(((FingerprintChemHasseNode )LargerNode).hFingerprint);
                buf = fpclone.ToHex();
                return(new string[] { buf });
            }

            return(ChemObject.GetDifferenceString(LargerNode));
        }
        public override bool GetMaxCommonFragments(
        HasseNode Node1, HasseNode Node2,
        bool dbg, HasseFragmentInsertionQueue NewFragmentList,
        int MinimumOverlap)
        {
            string debugInfo = "";
            HasseFingerprint fp1 = ((FingerprintChemHasseNode)Node1).hFingerprint;
            HasseFingerprint fp1_clone = fp1.CloneHasseFingerprint();
            HasseFingerprint fp2 = ((FingerprintChemHasseNode)Node2).hFingerprint;
            fp1_clone.AndBits(fp2);
            if(fp1_clone.bitCount >= MinimumOverlap ){
                string strMCS = fp1_clone.ToHex();

                HasseFingerprint test = new HasseFingerprint();
                test.FromHex(strMCS);

            NewFragmentList.Add(
                           new HasseNode[1] { this }, // this is lower than new frag
                           new HasseNode[2] { Node1, Node2 }, // those are higher than new frag
                           strMCS, // string to use for new node creation later
                           debugInfo, HasseNode.HasseNodeTypes.FRAGMENT | HasseNode.HasseNodeTypes.MAX_COMMON_FRAGMENT, // type of frag
                           null // this new frag is not associated with a single edge
                           );
                return true;
            }
            return false;
        }
Example #18
0
 public void AndBits(HasseFingerprint FP)
 {
     fp.And(FP.fp);
     this.bitCount = this.CountBits();
 }
Example #19
0
 public bool ContainsFingerprintOf(HasseFingerprint  fp )
 {
     return hFingerprint.ContainsAllBitsOf(fp);
 }
Example #20
0
 public bool ContainsFingerprintOf(HasseFingerprint fp)
 {
     return(hFingerprint.ContainsAllBitsOf(fp));
 }
 public void AndBits(HasseFingerprint FP)
 {
     fp.And(FP.fp );
     this.bitCount = this.CountBits();
 }
 public bool IsLargerThan(HasseFingerprint F)
 {
     //       if (HasAllBits == true) System.Diagnostics.Debugger.Break();
     if (this.bitCount <= F.bitCount) return false; // this must be larger
     bool HasAllBits = ContainsAllBitsOf(F);
     if (HasAllBits ) return true;
     return false;
 }
 public void Minus(HasseFingerprint FP)
 {
     // do this AND (NOT that)
     BitArray fpx= new BitArray (FP.fp);
     fpx.Not ();
     fp.And(fpx);
     this.bitCount = this.CountBits();
 }