2 // 22:05:28 cmzmasek Exp $
4 // FORESTER -- software libraries and applications
5 // for evolutionary biology research and applications.
7 // Copyright (C) 2008-2009 Christian M. Zmasek
8 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 // Contact: phylosoft @ gmail . com
26 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
28 package org.forester.surfacing;
30 public class ProteinCountsBasedPairwiseDomainSimilarityCalculator implements PairwiseDomainSimilarityCalculator {
33 public PairwiseDomainSimilarity calculateSimilarity( final CombinableDomains domains_1,
34 final CombinableDomains domains_2 ) {
35 if ( !domains_1.getKeyDomain().equals( domains_2.getKeyDomain() ) ) {
36 throw new IllegalArgumentException( "attempt to calculate similarity between domain collection with different keys" );
38 final int pc1 = domains_1.getKeyDomainProteinsCount();
39 final int pc2 = domains_2.getKeyDomainProteinsCount();
40 return new CountsBasedPairwiseDomainSimilarity( pc1 - pc2, pc1 + pc2 );