<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 431,  comments - 344,  trackbacks - 0

    /*  $RCSfile$
     *  $Author$
     *  $Date$
     *  $Revision$
     *
     *  Copyright (C) 1997-2007  The Chemistry Development Kit (CDK) project
     *
     *  Contact: cdk-devel@lists.sourceforge.net
     *
     *  This program is free software; you can redistribute it and/or
     *  modify it under the terms of the GNU Lesser General Public License
     *  as published by the Free Software Foundation; either version 2.1
     *  of the License, or (at your option) any later version.
     *  All we ask is that proper credit is given for our work, which includes
     *  - but is not limited to - adding the above copyright notice to the beginning
     *  of your source code files, and to any copyright notice that you may distribute
     *  with programs based on this work.
     *
     *  This program is distributed in the hope that it will be useful,
     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *  GNU Lesser General Public License for more details.
     *
     *  You should have received a copy of the GNU Lesser General Public License
     *  along with this program; if not, write to the Free Software
     *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
     *
     */
    package org.openscience.cdk.similarity;


    import org.openscience.cdk.annotations.TestClass;
    import org.openscience.cdk.annotations.TestMethod;
    import org.openscience.cdk.exception.CDKException;

    import Java.util.BitSet;

    /**
     *  Calculates the Tanimoto coefficient for a given pair of two
     *  fingerprint bitsets or real valued feature vectors.
     *
     *  The Tanimoto coefficient is one way to
     *  quantitatively measure the "distance" or similarity of
     *  two chemical structures.
     *
     *  <p>You can use the FingerPrinter class to retrieve two fingerprint bitsets.
     *  We assume that you have two structures stored in cdk.Molecule objects.
     *  A tanimoto coefficient can then be calculated like:
     *  <pre>
     *   BitSet fingerprint1 = Fingerprinter.getFingerprint(molecule1);
     *   BitSet fingerprint2 = Fingerprinter.getFingerprint(molecule2);
     *   float tanimoto_coefficient = Tanimoto.calculate(fingerprint1, fingerprint2);
     *  </pre>
     *
     *  <p>The FingerPrinter assumes that hydrogens are explicitely given, if this
     *  is desired!
     *  <p>Note that the continuous Tanimoto coefficient does not lead to a metric space
     *
     *@author         steinbeck
     * @cdk.githash
     *@cdk.created    2005-10-19
     *@cdk.keyword    jaccard
     *@cdk.keyword    similarity, tanimoto
     * @cdk.module fingerprint
     */
    @TestClass("org.openscience.cdk.similarity.TanimotoTest")
    public class Tanimoto
    {

        /**
         * Evaluates Tanimoto coefficient for two bit sets.
         *
         * @param bitset1 A bitset (such as a fingerprint) for the first molecule
         * @param bitset2 A bitset (such as a fingerprint) for the second molecule
         * @return The Tanimoto coefficient
         * @throws org.openscience.cdk.exception.CDKException  if bitsets are not of the same length
         */
        @TestMethod("testTanimoto1,testTanimoto2")
        public static float calculate(BitSet bitset1, BitSet bitset2) throws CDKException
        {
            float _bitset1_cardinality = bitset1.cardinality();
            float _bitset2_cardinality = bitset2.cardinality();
            if (bitset1.size() != bitset2.size()) {
                throw new CDKException("Bisets must have the same bit length");
            }
            BitSet one_and_two = (BitSet)bitset1.clone();
            one_and_two.and(bitset2);
            float _common_bit_count = one_and_two.cardinality();
            return _common_bit_count/(_bitset1_cardinality + _bitset2_cardinality - _common_bit_count);
        }
       
        /**
         * Evaluates the continuous Tanimoto coefficient for two real valued vectors.
         *
         * @param features1 The first feature vector
         * @param features2 The second feature vector
         * @return The continuous Tanimoto coefficient
         * @throws org.openscience.cdk.exception.CDKException  if the features are not of the same length
         */
        @TestMethod("testTanimoto3")
        public static float calculate(double[] features1, double[] features2) throws CDKException {

            if (features1.length != features2.length) {
                throw new CDKException("Features vectors must be of the same length");
            }

            int n = features1.length;
            double ab = 0.0;
            double a2 = 0.0;
            double b2 = 0.0;

            for (int i = 0; i < n; i++) {
                ab += features1[i] * features2[i];
                a2 += features1[i]*features1[i];
                b2 += features2[i]*features2[i];
            }
            return (float)ab/(float)(a2+b2-ab);
        }
    }

    通過源碼可以看出calculate(BitSet bitset1, BitSet bitset2)方法,是通過比較兩個分子的fingerprint的位,來計算相似度.通過BitSet的and操作得到共同的個數,然后在除以總共為true的個數,這樣就得到相似值.

    posted on 2009-10-18 13:36 周銳 閱讀(494) 評論(0)  編輯  收藏 所屬分類: ChemistryJavaCDK
    主站蜘蛛池模板: 亚洲精品无码中文久久字幕| 毛片免费全部播放无码| 成人性生免费视频| 456亚洲人成在线播放网站| 最近高清中文字幕免费| 久久久久亚洲AV成人片| 巨波霸乳在线永久免费视频| 亚洲成人福利在线观看| 无码区日韩特区永久免费系列| 亚洲成年人电影在线观看| 啦啦啦中文在线观看电视剧免费版 | 无码人妻一区二区三区免费n鬼沢| 久久久久亚洲AV成人网| 99re6在线精品免费观看| 好看的亚洲黄色经典| 久久久久久影院久久久久免费精品国产小说 | 在线永久看片免费的视频| 学生妹亚洲一区二区| 免费大学生国产在线观看p| 一级中文字幕免费乱码专区| 国产V亚洲V天堂无码久久久| 99久久精品免费精品国产| 亚洲国产精品白丝在线观看| 免费毛片在线视频| 久久er国产精品免费观看8| 久久久综合亚洲色一区二区三区| a拍拍男女免费看全片| 亚洲av午夜电影在线观看| 亚洲日韩人妻第一页| 一级毛片全部免费播放| 亚洲色在线无码国产精品不卡 | 婷婷亚洲久悠悠色悠在线播放| 青青视频观看免费99| 日本中文字幕免费看| 亚洲自偷自偷精品| 免费看的黄色大片| 久久成人18免费网站| 亚洲AV无码一区二区三区在线| 亚洲成aⅴ人片久青草影院| 美女在线视频观看影院免费天天看 | 在线免费观看中文字幕|