3 // FORESTER -- software libraries and applications
4 // for evolutionary biology research and applications.
6 // Copyright (C) 2008-2009 Christian M. Zmasek
7 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 // Contact: phylosoft @ gmail . com
25 // WWW: www.phylosoft.org/forester
27 package org.forester.surfacing;
30 import java.util.ArrayList;
31 import java.util.HashMap;
32 import java.util.HashSet;
33 import java.util.Iterator;
34 import java.util.List;
37 import java.util.SortedSet;
38 import java.util.TreeSet;
40 import org.forester.evoinference.matrix.character.BasicCharacterStateMatrix;
41 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
42 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
43 import org.forester.evoinference.matrix.character.CharacterStateMatrix.GainLossStates;
44 import org.forester.io.parsers.HmmPfamOutputParser;
45 import org.forester.io.parsers.nexus.PaupLogParser;
46 import org.forester.io.parsers.nhx.NHXParser;
47 import org.forester.phylogeny.Phylogeny;
48 import org.forester.phylogeny.PhylogenyNode;
49 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
50 import org.forester.phylogeny.factories.PhylogenyFactory;
51 import org.forester.surfacing.BinaryDomainCombination.DomainCombinationType;
52 import org.forester.test.Test;
53 import org.forester.util.ForesterUtil;
55 @SuppressWarnings( "unused")
56 public class TestSurfacing {
58 private final static double ZERO_DIFF = 1.0E-9;
60 public static boolean isEqual( final double a, final double b ) {
61 return ( ( Math.abs( a - b ) ) < TestSurfacing.ZERO_DIFF );
64 private static StringBuffer mapToStringBuffer( final Map<PhylogenyNode, CharacterStateMatrix.BinaryStates> map ) {
65 final StringBuffer sb = new StringBuffer();
66 for( final PhylogenyNode key : map.keySet() ) {
67 if ( !key.isExternal() ) {
68 sb.append( key.getName() );
70 sb.append( map.get( key ).toString() );
71 sb.append( ForesterUtil.getLineSeparator() );
77 public static boolean test( final File test_dir ) {
78 System.out.print( " Domain id: " );
79 if ( !TestSurfacing.testDomainId() ) {
80 System.out.println( "failed." );
83 System.out.println( "OK." );
84 System.out.print( " Protein id: " );
85 if ( !TestSurfacing.testProteinId() ) {
86 System.out.println( "failed." );
89 System.out.println( "OK." );
90 System.out.print( " Species: " );
91 if ( !TestSurfacing.testSpecies() ) {
92 System.out.println( "failed." );
95 System.out.println( "OK." );
96 System.out.print( " Basic domain: " );
97 if ( !TestSurfacing.testBasicDomain() ) {
98 System.out.println( "failed." );
101 System.out.println( "OK." );
102 System.out.print( " Basic protein: " );
103 if ( !TestSurfacing.testBasicProtein() ) {
104 System.out.println( "failed." );
107 System.out.println( "OK." );
108 System.out.print( " Combinable domains: " );
109 if ( !TestSurfacing.testCombinableDomains() ) {
110 System.out.println( "failed." );
113 System.out.println( "OK." );
114 System.out.print( " Directed combinable domains: " );
115 if ( !TestSurfacing.testDirectedCombinableDomains() ) {
116 System.out.println( "failed." );
119 System.out.println( "OK." );
120 System.out.print( " Genome wide specific combinable domains: " );
121 if ( !TestSurfacing.testGenomeWideCombinableDomains() ) {
122 System.out.println( "failed." );
125 System.out.println( "OK." );
126 System.out.print( " Domain architecture based genome similarity calculator: " );
127 if ( !TestSurfacing.testDomainArchitectureBasedGenomeSimilarityCalculator() ) {
128 System.out.println( "failed." );
131 System.out.println( "OK." );
132 System.out.print( " Hmmpfam output parser: " );
133 if ( !TestSurfacing.testHmmPfamOutputParser( test_dir ) ) {
134 System.out.println( "failed." );
137 System.out.println( "OK." );
138 System.out.print( " Hmmpfam output parser with filter: " );
139 if ( !TestSurfacing.testHmmPfamOutputParserWithFilter( test_dir ) ) {
140 System.out.println( "failed." );
143 System.out.println( "OK." );
144 System.out.print( " Combinations based pairwise similarity calculator: " );
145 if ( !TestSurfacing.testCombinationsBasedPairwiseSimilarityCalculator() ) {
146 System.out.println( "failed." );
149 System.out.println( "OK." );
150 System.out.print( " Copy number based pairwise similarity calculator: " );
151 if ( !TestSurfacing.testCopyNumberBasedPairwiseSimilarityCalculator() ) {
154 System.out.println( "OK." );
155 System.out.print( " Domain combination counting: " );
156 if ( !TestSurfacing.testDomainCombinationCounting( test_dir ) ) {
157 System.out.println( "failed." );
160 System.out.println( "OK." );
161 System.out.print( " Basic domain similarity calculator: " );
162 if ( !TestSurfacing.testBasicDomainSimilarityCalculator() ) {
163 System.out.println( "failed." );
166 System.out.println( "OK." );
167 System.out.print( " Basic domain similarity calculator not ignoring species specific domains: " );
168 if ( !TestSurfacing.testBasicDomainSimilarityCalculatorNotIgnoringSpeciesSpeficDomains() ) {
169 System.out.println( "failed." );
172 System.out.println( "OK." );
173 System.out.print( " Basic domain similarity calculator removal of singles: " );
174 if ( !TestSurfacing.testBasicDomainSimilarityCalculatorRemovalOfSingles() ) {
175 System.out.println( "failed." );
178 System.out.println( "OK." );
179 System.out.print( " Domain sorting: " );
180 if ( !TestSurfacing.testDomainSorting() ) {
181 System.out.println( "failed." );
184 System.out.println( "OK." );
185 System.out.print( " Overlap removal: " );
186 if ( !TestSurfacing.testOverlapRemoval() ) {
187 System.out.println( "failed." );
190 System.out.println( "OK." );
191 System.out.print( " Engulfing overlap removal: " );
192 if ( !TestSurfacing.testEngulfingOverlapRemoval() ) {
193 System.out.println( "failed." );
196 System.out.println( "OK." );
197 System.out.print( " Binary domain combination: " );
198 if ( !TestSurfacing.testBinaryDomainCombination() ) {
199 System.out.println( "failed." );
202 System.out.println( "OK." );
203 System.out.print( " Parsimony: " );
204 if ( !TestSurfacing.testParsimony() ) {
205 System.out.println( "failed." );
208 System.out.println( "OK." );
209 System.out.print( " Directedness: " );
210 if ( !TestSurfacing.testDirectedness() ) {
211 System.out.println( "failed." );
214 System.out.println( "OK." );
215 System.out.print( " Directedness and adjacency: " );
216 if ( !TestSurfacing.testDirectednessAndAdjacency() ) {
217 System.out.println( "failed." );
220 System.out.println( "OK." );
221 System.out.print( " Dollo parsimony on secodary features: " );
222 if ( !TestSurfacing.testParsimonyOnSecondaryFeatures() ) {
223 System.out.println( "failed." );
226 System.out.println( "OK." );
227 System.out.print( " Paup log parser: " );
228 if ( !TestSurfacing.testPaupLogParser( test_dir ) ) {
229 System.out.println( "failed." );
232 System.out.println( "OK." );
233 System.out.print( " Binary state matrix to gain loss matrix: " );
234 if ( !TestSurfacing.testBinaryStateMatrixToGainLossMatrix( test_dir ) ) {
235 System.out.println( "failed." );
238 System.out.println( "OK." );
242 private static boolean testBasicDomain() {
244 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
245 if ( !pd.getDomainId().getId().equals( "id" ) ) {
248 if ( pd.getNumber() != 1 ) {
251 if ( pd.getTotalCount() != 4 ) {
254 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
257 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
258 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
259 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
260 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
261 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
262 if ( !a1.equals( a1 ) ) {
265 if ( !a1.equals( a1_copy ) ) {
268 if ( !a1.equals( a1_equal ) ) {
271 if ( !a1.equals( a2 ) ) {
274 if ( a1.equals( a3 ) ) {
277 if ( a1.compareTo( a1 ) != 0 ) {
280 if ( a1.compareTo( a1_copy ) != 0 ) {
283 if ( a1.compareTo( a1_equal ) != 0 ) {
286 if ( a1.compareTo( a2 ) != 0 ) {
289 if ( a1.compareTo( a3 ) != 0 ) {
293 catch ( final Exception e ) {
294 e.printStackTrace( System.out );
300 private static boolean testBasicDomainSimilarityCalculator() {
308 // m 2/(2+3) 0 4/(4+2)
313 // mean = ( 2/5 + 0 + 2/3 + 1/5 + 1/2 + 2/7 ) / 6
333 // m - 2/(2+3) 4/(4+2)
337 // mean = (2/5 + 2/3 + 1/2)/3 =
343 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
344 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
345 final Domain C = new BasicDomain( "C", 1, 2, ( short ) 1, ( short ) 1, 0.3, -12 );
346 final Domain D = new BasicDomain( "D", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
347 final Domain E = new BasicDomain( "E", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
348 final Domain F = new BasicDomain( "F", 1, 2, ( short ) 1, ( short ) 1, 0.01, -12 );
349 final Domain G = new BasicDomain( "G", 1, 2, ( short ) 1, ( short ) 1, 0.001, -12 );
350 final Domain X = new BasicDomain( "X", 1, 2, ( short ) 1, ( short ) 1, 0.0001, -12 );
351 if ( !TestSurfacing.isEqual( X.getPerSequenceScore(), -12 ) ) {
354 final Protein mouse_1 = new BasicProtein( "1", "mouse" );
355 final Protein rabbit_1 = new BasicProtein( "1", "rabbit" );
356 final Protein ciona_1 = new BasicProtein( "1", "ciona" );
357 final Protein nemve_1 = new BasicProtein( "1", "nemve" );
358 mouse_1.addProteinDomain( A );
359 mouse_1.addProteinDomain( B );
360 mouse_1.addProteinDomain( C );
361 mouse_1.addProteinDomain( D );
362 mouse_1.addProteinDomain( E );
363 rabbit_1.addProteinDomain( A );
364 rabbit_1.addProteinDomain( C );
365 rabbit_1.addProteinDomain( E );
366 rabbit_1.addProteinDomain( F );
367 rabbit_1.addProteinDomain( F );
368 rabbit_1.addProteinDomain( F );
369 rabbit_1.addProteinDomain( F );
370 rabbit_1.addProteinDomain( F );
371 rabbit_1.addProteinDomain( F );
372 ciona_1.addProteinDomain( A );
373 ciona_1.addProteinDomain( A );
374 ciona_1.addProteinDomain( A );
375 ciona_1.addProteinDomain( A );
376 ciona_1.addProteinDomain( A );
377 ciona_1.addProteinDomain( F );
378 ciona_1.addProteinDomain( G );
379 ciona_1.addProteinDomain( X );
380 nemve_1.addProteinDomain( A );
381 nemve_1.addProteinDomain( B );
382 nemve_1.addProteinDomain( C );
383 nemve_1.addProteinDomain( D );
384 nemve_1.addProteinDomain( E );
385 nemve_1.addProteinDomain( F );
386 nemve_1.addProteinDomain( G );
387 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
388 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
389 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
390 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
391 protein_list_mouse.add( mouse_1 );
392 protein_list_rabbit.add( rabbit_1 );
393 protein_list_ciona.add( ciona_1 );
394 protein_list_nemve.add( nemve_1 );
395 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
396 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
398 new BasicSpecies( "mouse" ) ) );
399 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
401 new BasicSpecies( "rabbit" ) ) );
402 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
404 new BasicSpecies( "ciona" ) ) );
405 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
407 new BasicSpecies( "nemve" ) ) );
408 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
411 final SortedSet<DomainSimilarity> sims = calc
412 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
416 final Iterator<DomainSimilarity> sims_it = sims.iterator();
417 final DomainSimilarity sa = sims_it.next();
418 if ( !sa.getDomainId().getId().equals( "A" ) ) {
421 if ( sa.getSpeciesData().size() != 4 ) {
424 if ( !sa.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
427 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
430 if ( !sa.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
433 if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
436 if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(),
437 ( 2.0 / 5 + 0 + 2.0 / 3 + 1.0 / 5 + 1.0 / 2 + 2.0 / 7 ) / 6 ) ) {
440 if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), ( 0.23410788192183737 ) ) ) {
443 if ( !TestSurfacing.isEqual( sa.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
446 if ( !TestSurfacing.isEqual( sa.getMinimalSimilarityScore(), ( 0.0 ) ) ) {
449 if ( sa.getN() != 6 ) {
452 if ( sa.getMaximalDifference() != 7 ) {
455 if ( sa.getMaximalDifferenceInCounts() != 3 ) {
458 final DomainSimilarity sb = sims_it.next();
459 if ( !sb.getDomainId().getId().equals( "B" ) ) {
462 if ( sb.getSpeciesData().size() != 2 ) {
465 if ( !sb.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
468 if ( !sb.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
471 if ( !TestSurfacing.isEqual( sb.getMeanSimilarityScore(), 2.0 / 3 ) ) {
474 if ( !TestSurfacing.isEqual( sb.getStandardDeviationOfSimilarityScore(), 0.0 ) ) {
477 if ( !TestSurfacing.isEqual( sb.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
480 if ( !TestSurfacing.isEqual( sb.getMinimalSimilarityScore(), ( 2.0 / 3 ) ) ) {
483 if ( sb.getN() != 1 ) {
486 if ( sb.getMaximalDifference() != 2 ) {
489 if ( sb.getMaximalDifferenceInCounts() != 2 ) {
492 final DomainSimilarity sc = sims_it.next();
493 if ( !sc.getDomainId().getId().equals( "C" ) ) {
496 if ( sc.getSpeciesData().size() != 3 ) {
499 if ( !sc.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
502 if ( !sc.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
505 if ( !sc.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
508 if ( !TestSurfacing.isEqual( sc.getMeanSimilarityScore(), ( 2.0 / 5 + 2.0 / 3 + 1.0 / 2 ) / 3 ) ) {
511 if ( !TestSurfacing.isEqual( sc.getStandardDeviationOfSimilarityScore(), 0.13471506281091264 ) ) {
514 if ( !TestSurfacing.isEqual( sc.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
517 if ( !TestSurfacing.isEqual( sc.getMinimalSimilarityScore(), ( 2.0 / 5 ) ) ) {
520 if ( sc.getN() != 3 ) {
523 if ( sc.getMaximalDifference() != 3 ) {
526 if ( sc.getMaximalDifferenceInCounts() != 3 ) {
529 // mouse : ....ABCDE.....
530 // rabbit: ....A.C.EFFF..
531 // ciona : AAAAA......FGX
532 // nemve : ....ABCDEFG...
536 // m 2/(2+3) 0 4/(4+2)
537 // r - 1/(1+5) 3/(3+3)
541 // mean = ( 2/5 + 0 + 2/3 + 1/6 + 1/2 + 2/8 ) / 6
545 final List<GenomeWideCombinableDomains> cdc_list2 = new ArrayList<GenomeWideCombinableDomains>();
546 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
548 new BasicSpecies( "mouse" ) ) );
549 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
551 new BasicSpecies( "rabbit" ) ) );
552 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
554 new BasicSpecies( "ciona" ) ) );
555 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
557 new BasicSpecies( "nemve" ) ) );
558 final DomainSimilarityCalculator calc2 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
561 final SortedSet<DomainSimilarity> sims2 = calc2
562 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
566 final Iterator<DomainSimilarity> sims_it2 = sims2.iterator();
567 final DomainSimilarity sa2 = sims_it2.next();
568 if ( !sa2.getDomainId().getId().equals( "A" ) ) {
571 if ( sa2.getSpeciesData().size() != 4 ) {
574 if ( !sa2.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
577 if ( !sa2.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
580 if ( !sa2.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
583 if ( !sa2.getSpeciesData().keySet().contains( new BasicSpecies( "rabbit" ) ) ) {
586 if ( !TestSurfacing.isEqual( sa2.getMeanSimilarityScore(),
587 ( 2.0 / 5 + 0 + 2.0 / 3 + 1.0 / 6 + 1.0 / 2 + 2.0 / 8 ) / 6 ) ) {
590 if ( !TestSurfacing.isEqual( sa2.getStandardDeviationOfSimilarityScore(), ( 0.2404663678647683 ) ) ) {
593 if ( !TestSurfacing.isEqual( sa2.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
596 if ( !TestSurfacing.isEqual( sa2.getMinimalSimilarityScore(), ( 0.0 ) ) ) {
599 if ( sa2.getN() != 6 ) {
602 if ( sa2.getMaximalDifference() != 8 ) {
605 if ( sa2.getMaximalDifferenceInCounts() != 3 ) {
608 final Protein ciona_2 = new BasicProtein( "2", "ciona" );
609 ciona_2.addProteinDomain( A );
610 ciona_2.addProteinDomain( A );
611 ciona_2.addProteinDomain( A );
612 ciona_2.addProteinDomain( B );
613 ciona_2.addProteinDomain( B );
614 ciona_2.addProteinDomain( B );
615 ciona_2.addProteinDomain( F );
616 ciona_2.addProteinDomain( F );
617 ciona_2.addProteinDomain( F );
618 ciona_2.addProteinDomain( F );
619 ciona_2.addProteinDomain( G );
620 ciona_2.addProteinDomain( X );
621 final Protein ciona_3 = new BasicProtein( "3", "ciona" );
622 ciona_3.addProteinDomain( A );
623 ciona_3.addProteinDomain( A );
624 ciona_3.addProteinDomain( A );
625 ciona_3.addProteinDomain( A );
626 ciona_3.addProteinDomain( B );
627 ciona_3.addProteinDomain( B );
628 ciona_3.addProteinDomain( X );
629 ciona_3.addProteinDomain( X );
630 protein_list_ciona.add( ciona_2 );
631 protein_list_ciona.add( ciona_3 );
632 final List<GenomeWideCombinableDomains> cdc_list3 = new ArrayList<GenomeWideCombinableDomains>();
633 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
635 new BasicSpecies( "mouse" ) ) );
636 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
638 new BasicSpecies( "rabbit" ) ) );
639 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
641 new BasicSpecies( "ciona" ) ) );
642 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
644 new BasicSpecies( "nemve" ) ) );
645 final DomainSimilarityCalculator calc3 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
648 final SortedSet<DomainSimilarity> sims3 = calc3
649 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
653 final Iterator<DomainSimilarity> sims_it3 = sims3.iterator();
654 final DomainSimilarity sa3 = sims_it3.next();
655 if ( !sa3.getDomainId().getId().equals( "A" ) ) {
658 final SpeciesSpecificDomainSimilariyData ssdsd = sa3.getSpeciesData().get( new BasicSpecies( "ciona" ) );
659 if ( ssdsd.getCombinableDomainIdToCountsMap().size() != 4 ) {
662 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
665 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
668 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
671 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
674 final List<GenomeWideCombinableDomains> cdc_list4 = new ArrayList<GenomeWideCombinableDomains>();
675 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
677 new BasicSpecies( "mouse" ) ) );
678 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
680 new BasicSpecies( "rabbit" ) ) );
681 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
683 new BasicSpecies( "ciona" ) ) );
685 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
687 new BasicSpecies( "nemve" ) ) );
688 final DomainSimilarityCalculator calc4 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
691 final SortedSet<DomainSimilarity> sims4 = calc4
692 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
696 final Iterator<DomainSimilarity> sims_it4 = sims4.iterator();
697 final DomainSimilarity sa4 = sims_it4.next();
698 if ( !sa4.getDomainId().getId().equals( "A" ) ) {
701 final SpeciesSpecificDomainSimilariyData ssdsd4 = sa4.getSpeciesData().get( new BasicSpecies( "ciona" ) );
702 if ( ssdsd4.getCombinableDomainIdToCountsMap().size() != 5 ) {
705 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "A" ) ) != 3 ) {
708 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
711 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
714 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
717 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
720 final SortedSet<DomainSimilarity> sims4_d = calc4
721 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list4, false, true );
722 final Iterator<DomainSimilarity> sims_it4_d = sims4_d.iterator();
723 final DomainSimilarity sa4_d = sims_it4_d.next();
724 if ( !sa4_d.getDomainId().getId().equals( "A" ) ) {
727 if ( sa4_d.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
730 if ( !TestSurfacing.isEqual( sa4_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
731 + 1 - 11.0 / 13 ) / 6.0 ) ) {
734 if ( !TestSurfacing.isEqual( sa4_d.getMaximalSimilarityScore(), 1.0 ) ) {
737 if ( !TestSurfacing.isEqual( sa4_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
740 if ( sa4_d.getN() != 6 ) {
743 final SortedSet<DomainSimilarity> sims4_p = calc4
744 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
748 final Iterator<DomainSimilarity> sims_it4_p = sims4_p.iterator();
749 final DomainSimilarity sa4_p = sims_it4_p.next();
750 if ( !sa4_p.getDomainId().getId().equals( "A" ) ) {
753 if ( sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
756 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "A" ) ) ) {
759 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "B" ) ) ) {
762 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "F" ) ) ) {
765 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "G" ) ) ) {
768 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "X" ) ) ) {
771 if ( !TestSurfacing.isEqual( sa4_p.getMeanSimilarityScore(),
772 ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
775 if ( !TestSurfacing.isEqual( sa4_p.getMaximalSimilarityScore(), 1 ) ) {
778 if ( !TestSurfacing.isEqual( sa4_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
781 if ( sa4_p.getN() != 6 ) {
784 final List<GenomeWideCombinableDomains> cdc_list5 = new ArrayList<GenomeWideCombinableDomains>();
785 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
787 new BasicSpecies( "mouse" ) ) );
788 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
790 new BasicSpecies( "rabbit" ) ) );
791 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
793 new BasicSpecies( "ciona" ) ) );
794 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
796 new BasicSpecies( "nemve" ) ) );
797 final SortedSet<DomainSimilarity> sims5_d = calc4
798 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list5, false, true );
799 final Iterator<DomainSimilarity> sims_it5_d = sims5_d.iterator();
800 final DomainSimilarity sa5_d = sims_it5_d.next();
801 if ( sa5_d.getSpecies().size() != 4 ) {
804 if ( !sa5_d.getSpecies().last().equals( new BasicSpecies( "rabbit" ) ) ) {
807 final SpeciesSpecificDomainSimilariyData ssdsd5 = sa5_d.getSpeciesData().get( new BasicSpecies( "ciona" ) );
808 if ( ssdsd5.getCombinableDomainIdToCountsMap().size() != 4 ) {
811 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
814 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
817 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
820 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
823 if ( !sa5_d.getDomainId().getId().equals( "A" ) ) {
826 final Species ciona = new BasicSpecies( "ciona" );
827 if ( sa5_d.getCombinableDomainIds( ciona ).size() != 4 ) {
830 if ( sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
833 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
836 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
839 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
842 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
845 if ( !TestSurfacing.isEqual( sa5_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
846 + 1 - 11.0 / 13 ) / 6.0 ) ) {
849 if ( !TestSurfacing.isEqual( sa5_d.getMaximalSimilarityScore(), 1.0 ) ) {
852 if ( !TestSurfacing.isEqual( sa5_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
855 if ( sa5_d.getN() != 6 ) {
858 if ( sa5_d.getMaximalDifference() != sa5_d.getMaximalDifferenceInCounts() ) {
861 if ( sa5_d.getMaximalDifference() != 11 ) {
864 if ( sa5_d.getMaximalDifferenceInCounts() != 11 ) {
867 final SortedSet<DomainSimilarity> sims5_p = calc4
868 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
872 final Iterator<DomainSimilarity> sims_it5_p = sims5_p.iterator();
873 final DomainSimilarity sa5_p = sims_it5_p.next();
874 if ( !sa5_p.getDomainId().getId().equals( "A" ) ) {
877 if ( sa5_p.getCombinableDomainIds( ciona ).size() != 4 ) {
880 if ( sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
883 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
886 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
889 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
892 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
895 if ( !TestSurfacing.isEqual( sa5_p.getMeanSimilarityScore(),
896 ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
899 if ( !TestSurfacing.isEqual( sa5_p.getMaximalSimilarityScore(), 1 ) ) {
902 if ( !TestSurfacing.isEqual( sa5_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
905 if ( sa5_p.getN() != 6 ) {
908 if ( sa5_p.getMaximalDifference() != sa5_p.getMaximalDifferenceInCounts() ) {
911 if ( sa5_p.getMaximalDifference() != 2 ) {
914 if ( sa5_p.getMaximalDifferenceInCounts() != 2 ) {
917 final List<GenomeWideCombinableDomains> cdc_list6 = new ArrayList<GenomeWideCombinableDomains>();
918 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
920 new BasicSpecies( "mouse" ) ) );
921 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
923 new BasicSpecies( "rabbit" ) ) );
924 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
926 new BasicSpecies( "ciona" ) ) );
927 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
929 new BasicSpecies( "nemve" ) ) );
930 final SortedSet<DomainSimilarity> sims6_d = calc4
931 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list6, false, true );
932 final Iterator<DomainSimilarity> sims_it6_d = sims6_d.iterator();
933 final DomainSimilarity sa6_d = sims_it6_d.next();
934 if ( sa6_d.getSpecies().size() != 4 ) {
937 if ( !sa6_d.getSpecies().last().equals( new BasicSpecies( "rabbit" ) ) ) {
940 final SpeciesSpecificDomainSimilariyData ssdsd6 = sa6_d.getSpeciesData().get( new BasicSpecies( "ciona" ) );
941 if ( ssdsd6.getCombinableDomainIdToCountsMap().size() != 5 ) {
944 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
947 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
950 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
953 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
956 if ( !sa5_d.getDomainId().getId().equals( "A" ) ) {
959 final Species ciona6 = new BasicSpecies( "ciona" );
960 if ( sa6_d.getCombinableDomainIds( ciona6 ).size() != 5 ) {
963 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "A" ) ) ) {
966 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "B" ) ) ) {
969 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "F" ) ) ) {
972 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "G" ) ) ) {
975 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "X" ) ) ) {
978 if ( !TestSurfacing.isEqual( sa6_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
979 + 1 - 11.0 / 13 ) / 6.0 ) ) {
982 if ( !TestSurfacing.isEqual( sa6_d.getMaximalSimilarityScore(), 1.0 ) ) {
985 if ( !TestSurfacing.isEqual( sa6_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
988 if ( sa6_d.getN() != 6 ) {
991 if ( sa6_d.getMaximalDifference() != sa6_d.getMaximalDifferenceInCounts() ) {
994 if ( sa6_d.getMaximalDifference() != 11 ) {
997 if ( sa6_d.getMaximalDifferenceInCounts() != 11 ) {
1000 final SortedSet<DomainSimilarity> sims6_p = calc4
1001 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
1005 final Iterator<DomainSimilarity> sims_it6_p = sims6_p.iterator();
1006 final DomainSimilarity sa6_p = sims_it6_p.next();
1007 if ( !sa6_p.getDomainId().getId().equals( "A" ) ) {
1010 if ( sa6_p.getCombinableDomainIds( ciona ).size() != 5 ) {
1013 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
1016 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
1019 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
1022 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
1025 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
1028 if ( !TestSurfacing.isEqual( sa6_p.getMeanSimilarityScore(),
1029 ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
1032 if ( !TestSurfacing.isEqual( sa6_p.getMaximalSimilarityScore(), 1 ) ) {
1035 if ( !TestSurfacing.isEqual( sa6_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
1038 if ( sa6_p.getN() != 6 ) {
1041 if ( sa6_p.getMaximalDifference() != sa6_p.getMaximalDifferenceInCounts() ) {
1044 if ( sa6_p.getMaximalDifference() != 2 ) {
1047 if ( sa6_p.getMaximalDifferenceInCounts() != 2 ) {
1051 catch ( final Exception e ) {
1052 e.printStackTrace( System.out );
1058 private static boolean testBasicDomainSimilarityCalculatorNotIgnoringSpeciesSpeficDomains() {
1060 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
1061 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
1062 final Domain D = new BasicDomain( "D", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
1063 final Domain E = new BasicDomain( "E", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
1064 final Domain F = new BasicDomain( "F", 1, 2, ( short ) 1, ( short ) 1, 0.01, -12 );
1065 final Domain G = new BasicDomain( "G", 1, 2, ( short ) 1, ( short ) 1, 0.001, -12 );
1066 final Domain X = new BasicDomain( "X", 1, 2, ( short ) 1, ( short ) 1, 0.0001, -12 );
1067 if ( !TestSurfacing.isEqual( X.getPerSequenceScore(), -12 ) ) {
1070 final Protein mouse_1 = new BasicProtein( "1", "mouse" );
1071 final Protein rabbit_1 = new BasicProtein( "1", "rabbit" );
1072 final Protein ciona_1 = new BasicProtein( "1", "ciona" );
1073 final Protein nemve_1 = new BasicProtein( "1", "nemve" );
1074 mouse_1.addProteinDomain( A );
1075 mouse_1.addProteinDomain( D );
1076 mouse_1.addProteinDomain( E );
1077 rabbit_1.addProteinDomain( B );
1078 rabbit_1.addProteinDomain( E );
1079 rabbit_1.addProteinDomain( F );
1080 rabbit_1.addProteinDomain( F );
1081 rabbit_1.addProteinDomain( F );
1082 rabbit_1.addProteinDomain( F );
1083 rabbit_1.addProteinDomain( F );
1084 rabbit_1.addProteinDomain( F );
1085 ciona_1.addProteinDomain( F );
1086 ciona_1.addProteinDomain( G );
1087 ciona_1.addProteinDomain( X );
1088 nemve_1.addProteinDomain( D );
1089 nemve_1.addProteinDomain( E );
1090 nemve_1.addProteinDomain( F );
1091 nemve_1.addProteinDomain( G );
1092 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
1093 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
1094 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
1095 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
1096 protein_list_mouse.add( mouse_1 );
1097 protein_list_rabbit.add( rabbit_1 );
1098 protein_list_ciona.add( ciona_1 );
1099 protein_list_nemve.add( nemve_1 );
1100 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
1101 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
1103 new BasicSpecies( "mouse" ) ) );
1104 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
1106 new BasicSpecies( "rabbit" ) ) );
1107 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
1109 new BasicSpecies( "ciona" ) ) );
1110 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
1112 new BasicSpecies( "nemve" ) ) );
1113 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
1116 final SortedSet<DomainSimilarity> sims = calc
1117 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1121 final Iterator<DomainSimilarity> sims_it = sims.iterator();
1122 final DomainSimilarity sa = sims_it.next();
1123 if ( !sa.getDomainId().getId().equals( "A" ) ) {
1126 if ( sa.getSpeciesData().size() != 1 ) {
1129 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
1132 if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(), 1.0 ) ) {
1135 if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), 0.0 ) ) {
1138 if ( !TestSurfacing.isEqual( sa.getMaximalSimilarityScore(), 1.0 ) ) {
1141 if ( !TestSurfacing.isEqual( sa.getMinimalSimilarityScore(), 1.0 ) ) {
1144 if ( sa.getN() != 0 ) {
1147 if ( sa.getMaximalDifference() != 0 ) {
1150 if ( sa.getMaximalDifferenceInCounts() != 0 ) {
1153 final DomainSimilarity sb = sims_it.next();
1154 if ( !sb.getDomainId().getId().equals( "B" ) ) {
1157 if ( sb.getSpeciesData().size() != 1 ) {
1160 if ( !sb.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
1163 final SortedSet<DomainSimilarity> sims2 = calc
1164 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1168 final Iterator<DomainSimilarity> sims_it2 = sims2.iterator();
1169 final DomainSimilarity sa2 = sims_it2.next();
1170 if ( !sa2.getDomainId().getId().equals( "D" ) ) {
1173 if ( sa2.getSpeciesData().size() != 2 ) {
1177 catch ( final Exception e ) {
1178 e.printStackTrace( System.out );
1184 private static boolean testBasicDomainSimilarityCalculatorRemovalOfSingles() {
1186 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
1187 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
1188 final Protein mouse_1 = new BasicProtein( "1", "mouse" );
1189 final Protein rabbit_1 = new BasicProtein( "1", "rabbit" );
1190 final Protein ciona_1 = new BasicProtein( "1", "ciona" );
1191 final Protein nemve_1 = new BasicProtein( "1", "nemve" );
1192 mouse_1.addProteinDomain( A );
1193 rabbit_1.addProteinDomain( A );
1194 ciona_1.addProteinDomain( A );
1195 ciona_1.addProteinDomain( A );
1196 ciona_1.addProteinDomain( A );
1197 ciona_1.addProteinDomain( A );
1198 ciona_1.addProteinDomain( A );
1199 nemve_1.addProteinDomain( A );
1200 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
1201 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
1202 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
1203 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
1204 protein_list_mouse.add( mouse_1 );
1205 protein_list_rabbit.add( rabbit_1 );
1206 protein_list_ciona.add( ciona_1 );
1207 protein_list_nemve.add( nemve_1 );
1208 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
1209 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
1211 new BasicSpecies( "mouse" ) ) );
1212 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
1214 new BasicSpecies( "rabbit" ) ) );
1215 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
1217 new BasicSpecies( "ciona" ) ) );
1218 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
1220 new BasicSpecies( "nemve" ) ) );
1221 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
1224 final SortedSet<DomainSimilarity> sims = calc
1225 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1229 if ( sims.size() != 1 ) {
1232 final Iterator<DomainSimilarity> sims_it = sims.iterator();
1233 final DomainSimilarity sa = sims_it.next();
1234 if ( !sa.getDomainId().getId().equals( "A" ) ) {
1237 if ( sa.getSpeciesData().size() != 4 ) {
1240 if ( !sa.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
1243 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
1246 if ( !sa.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
1249 if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
1252 final SortedSet<DomainSimilarity> sims_ns = calc
1253 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1257 if ( sims_ns.size() != 0 ) {
1260 final Protein mouse_2 = new BasicProtein( "1", "mouse" );
1261 final Protein rabbit_2 = new BasicProtein( "1", "rabbit" );
1262 final Protein ciona_2 = new BasicProtein( "1", "ciona" );
1263 final Protein nemve_2 = new BasicProtein( "1", "nemve" );
1264 mouse_2.addProteinDomain( A );
1265 rabbit_2.addProteinDomain( A );
1266 ciona_2.addProteinDomain( A );
1267 ciona_2.addProteinDomain( A );
1268 ciona_2.addProteinDomain( B );
1269 ciona_2.addProteinDomain( A );
1270 ciona_2.addProteinDomain( A );
1271 ciona_2.addProteinDomain( A );
1272 nemve_2.addProteinDomain( A );
1273 final List<Protein> protein_list_mouse2 = new ArrayList<Protein>();
1274 final List<Protein> protein_list_rabbit2 = new ArrayList<Protein>();
1275 final List<Protein> protein_list_ciona2 = new ArrayList<Protein>();
1276 final List<Protein> protein_list_nemve2 = new ArrayList<Protein>();
1277 protein_list_mouse2.add( mouse_2 );
1278 protein_list_rabbit2.add( rabbit_2 );
1279 protein_list_ciona2.add( ciona_2 );
1280 protein_list_nemve2.add( nemve_2 );
1281 final List<GenomeWideCombinableDomains> cdc_list2 = new ArrayList<GenomeWideCombinableDomains>();
1282 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse2,
1284 new BasicSpecies( "mouse" ) ) );
1285 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit2,
1287 new BasicSpecies( "rabbit" ) ) );
1288 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona2,
1290 new BasicSpecies( "ciona" ) ) );
1291 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve2,
1293 new BasicSpecies( "nemve" ) ) );
1294 final SortedSet<DomainSimilarity> sims2 = calc
1295 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1299 if ( sims2.size() != 1 ) {
1303 catch ( final Exception e ) {
1304 e.printStackTrace( System.out );
1310 private static boolean testBasicProtein() {
1312 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1313 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1314 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1315 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1316 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1317 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1318 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1319 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1320 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1321 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1322 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1323 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1324 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1325 final BasicProtein p = new BasicProtein( "p", "owl" );
1326 p.addProteinDomain( B15 );
1327 p.addProteinDomain( C50 );
1328 p.addProteinDomain( A60 );
1329 p.addProteinDomain( A30 );
1330 p.addProteinDomain( C70 );
1331 p.addProteinDomain( B35 );
1332 p.addProteinDomain( B40 );
1333 p.addProteinDomain( A0 );
1334 p.addProteinDomain( A10 );
1335 p.addProteinDomain( A20 );
1336 p.addProteinDomain( B25 );
1337 p.addProteinDomain( D80 );
1338 List<DomainId> domains_ids = new ArrayList<DomainId>();
1339 domains_ids.add( new DomainId( "A" ) );
1340 domains_ids.add( new DomainId( "B" ) );
1341 domains_ids.add( new DomainId( "C" ) );
1342 if ( !p.contains( domains_ids, false ) ) {
1345 if ( !p.contains( domains_ids, true ) ) {
1348 domains_ids.add( new DomainId( "X" ) );
1349 if ( p.contains( domains_ids, false ) ) {
1352 if ( p.contains( domains_ids, true ) ) {
1355 domains_ids = new ArrayList<DomainId>();
1356 domains_ids.add( new DomainId( "A" ) );
1357 domains_ids.add( new DomainId( "C" ) );
1358 domains_ids.add( new DomainId( "D" ) );
1359 if ( !p.contains( domains_ids, false ) ) {
1362 if ( !p.contains( domains_ids, true ) ) {
1365 domains_ids = new ArrayList<DomainId>();
1366 domains_ids.add( new DomainId( "A" ) );
1367 domains_ids.add( new DomainId( "D" ) );
1368 domains_ids.add( new DomainId( "C" ) );
1369 if ( !p.contains( domains_ids, false ) ) {
1372 if ( p.contains( domains_ids, true ) ) {
1375 domains_ids = new ArrayList<DomainId>();
1376 domains_ids.add( new DomainId( "A" ) );
1377 domains_ids.add( new DomainId( "A" ) );
1378 domains_ids.add( new DomainId( "B" ) );
1379 if ( !p.contains( domains_ids, false ) ) {
1382 if ( !p.contains( domains_ids, true ) ) {
1385 domains_ids = new ArrayList<DomainId>();
1386 domains_ids.add( new DomainId( "A" ) );
1387 domains_ids.add( new DomainId( "A" ) );
1388 domains_ids.add( new DomainId( "A" ) );
1389 domains_ids.add( new DomainId( "B" ) );
1390 domains_ids.add( new DomainId( "B" ) );
1391 if ( !p.contains( domains_ids, false ) ) {
1394 if ( !p.contains( domains_ids, true ) ) {
1397 domains_ids = new ArrayList<DomainId>();
1398 domains_ids.add( new DomainId( "A" ) );
1399 domains_ids.add( new DomainId( "A" ) );
1400 domains_ids.add( new DomainId( "A" ) );
1401 domains_ids.add( new DomainId( "A" ) );
1402 domains_ids.add( new DomainId( "B" ) );
1403 domains_ids.add( new DomainId( "B" ) );
1404 if ( !p.contains( domains_ids, false ) ) {
1407 if ( !p.contains( domains_ids, true ) ) {
1410 domains_ids = new ArrayList<DomainId>();
1411 domains_ids.add( new DomainId( "A" ) );
1412 domains_ids.add( new DomainId( "A" ) );
1413 domains_ids.add( new DomainId( "A" ) );
1414 domains_ids.add( new DomainId( "A" ) );
1415 domains_ids.add( new DomainId( "A" ) );
1416 domains_ids.add( new DomainId( "B" ) );
1417 domains_ids.add( new DomainId( "B" ) );
1418 if ( !p.contains( domains_ids, false ) ) {
1421 if ( p.contains( domains_ids, true ) ) {
1424 domains_ids = new ArrayList<DomainId>();
1425 domains_ids.add( new DomainId( "A" ) );
1426 domains_ids.add( new DomainId( "A" ) );
1427 domains_ids.add( new DomainId( "B" ) );
1428 domains_ids.add( new DomainId( "A" ) );
1429 domains_ids.add( new DomainId( "B" ) );
1430 domains_ids.add( new DomainId( "A" ) );
1431 domains_ids.add( new DomainId( "B" ) );
1432 domains_ids.add( new DomainId( "B" ) );
1433 domains_ids.add( new DomainId( "C" ) );
1434 domains_ids.add( new DomainId( "A" ) );
1435 domains_ids.add( new DomainId( "C" ) );
1436 domains_ids.add( new DomainId( "D" ) );
1437 if ( !p.contains( domains_ids, false ) ) {
1440 if ( !p.contains( domains_ids, true ) ) {
1443 domains_ids = new ArrayList<DomainId>();
1444 domains_ids.add( new DomainId( "A" ) );
1445 domains_ids.add( new DomainId( "B" ) );
1446 domains_ids.add( new DomainId( "A" ) );
1447 domains_ids.add( new DomainId( "B" ) );
1448 domains_ids.add( new DomainId( "A" ) );
1449 domains_ids.add( new DomainId( "B" ) );
1450 domains_ids.add( new DomainId( "B" ) );
1451 domains_ids.add( new DomainId( "A" ) );
1452 domains_ids.add( new DomainId( "C" ) );
1453 domains_ids.add( new DomainId( "D" ) );
1454 if ( !p.contains( domains_ids, false ) ) {
1457 if ( !p.contains( domains_ids, true ) ) {
1460 domains_ids = new ArrayList<DomainId>();
1461 domains_ids.add( new DomainId( "A" ) );
1462 domains_ids.add( new DomainId( "A" ) );
1463 domains_ids.add( new DomainId( "B" ) );
1464 domains_ids.add( new DomainId( "A" ) );
1465 domains_ids.add( new DomainId( "B" ) );
1466 domains_ids.add( new DomainId( "A" ) );
1467 domains_ids.add( new DomainId( "B" ) );
1468 domains_ids.add( new DomainId( "B" ) );
1469 domains_ids.add( new DomainId( "C" ) );
1470 domains_ids.add( new DomainId( "C" ) );
1471 domains_ids.add( new DomainId( "A" ) );
1472 domains_ids.add( new DomainId( "C" ) );
1473 domains_ids.add( new DomainId( "D" ) );
1474 if ( !p.contains( domains_ids, false ) ) {
1477 if ( p.contains( domains_ids, true ) ) {
1480 domains_ids = new ArrayList<DomainId>();
1481 domains_ids.add( new DomainId( "A" ) );
1482 domains_ids.add( new DomainId( "A" ) );
1483 domains_ids.add( new DomainId( "A" ) );
1484 domains_ids.add( new DomainId( "B" ) );
1485 domains_ids.add( new DomainId( "A" ) );
1486 domains_ids.add( new DomainId( "B" ) );
1487 domains_ids.add( new DomainId( "A" ) );
1488 domains_ids.add( new DomainId( "B" ) );
1489 domains_ids.add( new DomainId( "B" ) );
1490 domains_ids.add( new DomainId( "C" ) );
1491 domains_ids.add( new DomainId( "A" ) );
1492 domains_ids.add( new DomainId( "C" ) );
1493 domains_ids.add( new DomainId( "D" ) );
1494 if ( !p.contains( domains_ids, false ) ) {
1497 if ( p.contains( domains_ids, true ) ) {
1500 domains_ids = new ArrayList<DomainId>();
1501 domains_ids.add( new DomainId( "A" ) );
1502 domains_ids.add( new DomainId( "A" ) );
1503 domains_ids.add( new DomainId( "B" ) );
1504 domains_ids.add( new DomainId( "A" ) );
1505 domains_ids.add( new DomainId( "B" ) );
1506 domains_ids.add( new DomainId( "A" ) );
1507 domains_ids.add( new DomainId( "B" ) );
1508 domains_ids.add( new DomainId( "B" ) );
1509 domains_ids.add( new DomainId( "A" ) );
1510 domains_ids.add( new DomainId( "D" ) );
1511 if ( !p.contains( domains_ids, false ) ) {
1514 if ( !p.contains( domains_ids, true ) ) {
1517 domains_ids = new ArrayList<DomainId>();
1518 domains_ids.add( new DomainId( "A" ) );
1519 domains_ids.add( new DomainId( "A" ) );
1520 domains_ids.add( new DomainId( "B" ) );
1521 domains_ids.add( new DomainId( "A" ) );
1522 domains_ids.add( new DomainId( "B" ) );
1523 domains_ids.add( new DomainId( "A" ) );
1524 domains_ids.add( new DomainId( "B" ) );
1525 domains_ids.add( new DomainId( "B" ) );
1526 domains_ids.add( new DomainId( "C" ) );
1527 domains_ids.add( new DomainId( "A" ) );
1528 domains_ids.add( new DomainId( "C" ) );
1529 domains_ids.add( new DomainId( "D" ) );
1530 domains_ids.add( new DomainId( "X" ) );
1531 if ( p.contains( domains_ids, false ) ) {
1534 if ( p.contains( domains_ids, true ) ) {
1537 domains_ids = new ArrayList<DomainId>();
1538 domains_ids.add( new DomainId( "X" ) );
1539 domains_ids.add( new DomainId( "A" ) );
1540 domains_ids.add( new DomainId( "A" ) );
1541 domains_ids.add( new DomainId( "B" ) );
1542 domains_ids.add( new DomainId( "A" ) );
1543 domains_ids.add( new DomainId( "B" ) );
1544 domains_ids.add( new DomainId( "A" ) );
1545 domains_ids.add( new DomainId( "B" ) );
1546 domains_ids.add( new DomainId( "B" ) );
1547 domains_ids.add( new DomainId( "C" ) );
1548 domains_ids.add( new DomainId( "A" ) );
1549 domains_ids.add( new DomainId( "C" ) );
1550 domains_ids.add( new DomainId( "D" ) );
1551 if ( p.contains( domains_ids, false ) ) {
1554 if ( p.contains( domains_ids, true ) ) {
1557 domains_ids = new ArrayList<DomainId>();
1558 domains_ids.add( new DomainId( "A" ) );
1559 domains_ids.add( new DomainId( "A" ) );
1560 domains_ids.add( new DomainId( "B" ) );
1561 domains_ids.add( new DomainId( "A" ) );
1562 domains_ids.add( new DomainId( "B" ) );
1563 domains_ids.add( new DomainId( "B" ) );
1564 domains_ids.add( new DomainId( "A" ) );
1565 domains_ids.add( new DomainId( "B" ) );
1566 domains_ids.add( new DomainId( "C" ) );
1567 domains_ids.add( new DomainId( "A" ) );
1568 domains_ids.add( new DomainId( "C" ) );
1569 domains_ids.add( new DomainId( "D" ) );
1570 if ( !p.contains( domains_ids, false ) ) {
1573 if ( p.contains( domains_ids, true ) ) {
1577 catch ( final Exception e ) {
1578 e.printStackTrace( System.out );
1584 private static boolean testBinaryDomainCombination() {
1586 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "a", "a" );
1587 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "a" );
1588 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "a", "b" );
1589 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "B", "A" );
1590 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "A", "B" );
1591 final BasicBinaryDomainCombination s5 = new BasicBinaryDomainCombination( "c", "a" );
1592 final BasicBinaryDomainCombination s6 = new BasicBinaryDomainCombination( "b", "c" );
1593 final BasicBinaryDomainCombination s7 = new BasicBinaryDomainCombination( "d", "a" );
1594 final BasicBinaryDomainCombination s8 = new BasicBinaryDomainCombination( "b", "d" );
1595 final BinaryDomainCombination s9 = BasicBinaryDomainCombination.createInstance( " z-z=a-aa " );
1596 if ( !s9.toString().equals( "a-aa=z-z" ) ) {
1597 System.out.println( s9.toString() );
1600 if ( !s0.equals( s0 ) ) {
1603 if ( s0.equals( s1 ) ) {
1606 if ( s1.equals( s0 ) ) {
1609 if ( !s1.equals( s2 ) ) {
1612 if ( !s2.equals( s1 ) ) {
1615 if ( s2.equals( s3 ) ) {
1618 if ( s2.equals( s3 ) ) {
1621 if ( s2.equals( s4 ) ) {
1624 final SortedSet<BasicBinaryDomainCombination> sorted = new TreeSet<BasicBinaryDomainCombination>();
1637 if ( sorted.size() != 6 ) {
1640 final DirectedBinaryDomainCombination aa = new DirectedBinaryDomainCombination( "a", "a" );
1641 final DirectedBinaryDomainCombination ba = new DirectedBinaryDomainCombination( "b", "a" );
1642 final DirectedBinaryDomainCombination ab = new DirectedBinaryDomainCombination( "a", "b" );
1643 final DirectedBinaryDomainCombination bb = new DirectedBinaryDomainCombination( "b", "b" );
1644 if ( !aa.equals( aa ) ) {
1647 if ( aa.equals( bb ) ) {
1650 if ( ab.equals( ba ) ) {
1653 if ( ba.equals( ab ) ) {
1656 if ( !ab.equals( ab ) ) {
1659 if ( ab.equals( aa ) ) {
1662 if ( ab.equals( bb ) ) {
1666 catch ( final Exception e ) {
1667 e.printStackTrace( System.out );
1673 private static boolean testBinaryStateMatrixToGainLossMatrix( final File test_dir ) {
1674 final BinaryStates I = BinaryStates.PRESENT;
1675 final BinaryStates O = BinaryStates.ABSENT;
1677 final CharacterStateMatrix<BinaryStates> binary_states_matrix_0 = new BasicCharacterStateMatrix<BinaryStates>( 7,
1679 binary_states_matrix_0.setIdentifier( 0, "A" );
1680 binary_states_matrix_0.setIdentifier( 1, "B" );
1681 binary_states_matrix_0.setIdentifier( 2, "C" );
1682 binary_states_matrix_0.setIdentifier( 3, "D" );
1683 binary_states_matrix_0.setIdentifier( 4, "1" );
1684 binary_states_matrix_0.setIdentifier( 5, "2" );
1685 binary_states_matrix_0.setIdentifier( 6, "3" );
1686 binary_states_matrix_0.setState( 0, 0, O );
1687 binary_states_matrix_0.setState( 1, 0, O );
1688 binary_states_matrix_0.setState( 2, 0, O );
1689 binary_states_matrix_0.setState( 3, 0, O );
1690 binary_states_matrix_0.setState( 4, 0, O );
1691 binary_states_matrix_0.setState( 5, 0, O );
1692 binary_states_matrix_0.setState( 6, 0, O );
1693 binary_states_matrix_0.setState( 0, 1, I );
1694 binary_states_matrix_0.setState( 1, 1, O );
1695 binary_states_matrix_0.setState( 2, 1, O );
1696 binary_states_matrix_0.setState( 3, 1, O );
1697 binary_states_matrix_0.setState( 4, 1, O );
1698 binary_states_matrix_0.setState( 5, 1, O );
1699 binary_states_matrix_0.setState( 6, 1, O );
1700 binary_states_matrix_0.setState( 0, 2, O );
1701 binary_states_matrix_0.setState( 1, 2, O );
1702 binary_states_matrix_0.setState( 2, 2, O );
1703 binary_states_matrix_0.setState( 3, 2, O );
1704 binary_states_matrix_0.setState( 4, 2, I );
1705 binary_states_matrix_0.setState( 5, 2, O );
1706 binary_states_matrix_0.setState( 6, 2, O );
1707 binary_states_matrix_0.setState( 0, 3, I );
1708 binary_states_matrix_0.setState( 1, 3, O );
1709 binary_states_matrix_0.setState( 2, 3, O );
1710 binary_states_matrix_0.setState( 3, 3, O );
1711 binary_states_matrix_0.setState( 4, 3, I );
1712 binary_states_matrix_0.setState( 5, 3, O );
1713 binary_states_matrix_0.setState( 6, 3, I );
1714 binary_states_matrix_0.setState( 0, 4, I );
1715 binary_states_matrix_0.setState( 1, 4, O );
1716 binary_states_matrix_0.setState( 2, 4, I );
1717 binary_states_matrix_0.setState( 3, 4, O );
1718 binary_states_matrix_0.setState( 4, 4, I );
1719 binary_states_matrix_0.setState( 5, 4, O );
1720 binary_states_matrix_0.setState( 6, 4, I );
1721 binary_states_matrix_0.setState( 0, 5, I );
1722 binary_states_matrix_0.setState( 1, 5, I );
1723 binary_states_matrix_0.setState( 2, 5, I );
1724 binary_states_matrix_0.setState( 3, 5, I );
1725 binary_states_matrix_0.setState( 4, 5, I );
1726 binary_states_matrix_0.setState( 5, 5, I );
1727 binary_states_matrix_0.setState( 6, 5, I );
1728 final String[] character_labels_0 = new String[ 6 ];
1729 character_labels_0[ 0 ] = "first";
1730 character_labels_0[ 1 ] = "second";
1731 character_labels_0[ 2 ] = "third";
1732 character_labels_0[ 3 ] = "forth";
1733 character_labels_0[ 4 ] = "fifth";
1734 character_labels_0[ 5 ] = "sixth";
1735 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1736 final Phylogeny phylogeny_0 = factory.create( "(((A,B)1,C)2,D)3", new NHXParser() )[ 0 ];
1737 final DomainParsimonyCalculator dom_pars = DomainParsimonyCalculator.createInstance( phylogeny_0 );
1738 dom_pars.executeOnGivenBinaryStatesMatrix( binary_states_matrix_0, character_labels_0 );
1739 final CharacterStateMatrix<GainLossStates> gl_matrix_0 = dom_pars.getGainLossMatrix();
1740 // final StringWriter sw = new StringWriter();
1741 // gl_matrix_0.toWriter( sw );
1742 // System.out.println( sw.toString() );
1743 if ( dom_pars.getCost() != 13 ) {
1746 if ( dom_pars.getTotalGains() != 5 ) {
1749 if ( dom_pars.getTotalLosses() != 8 ) {
1752 if ( dom_pars.getTotalUnchanged() != 29 ) {
1755 if ( gl_matrix_0.getState( "A", 1 ) != GainLossStates.GAIN ) {
1758 if ( gl_matrix_0.getState( "A", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1761 if ( gl_matrix_0.getState( "B", 4 ) != GainLossStates.LOSS ) {
1764 if ( gl_matrix_0.getState( "C", 4 ) != GainLossStates.GAIN ) {
1767 if ( gl_matrix_0.getState( "D", 4 ) != GainLossStates.LOSS ) {
1770 if ( gl_matrix_0.getState( "1", 4 ) != GainLossStates.GAIN ) {
1773 if ( gl_matrix_0.getState( "2", 4 ) != GainLossStates.LOSS ) {
1776 if ( gl_matrix_0.getState( "3", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1780 catch ( final Exception e ) {
1781 e.printStackTrace( System.out );
1787 private static boolean testCombinableDomains() {
1789 final Domain key0 = new BasicDomain( "key0", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1790 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1791 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1792 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1793 final CombinableDomains cd0 = new BasicCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
1794 cd0.addCombinableDomain( a.getDomainId() );
1795 cd0.addCombinableDomain( b.getDomainId() );
1796 cd0.addCombinableDomain( b.getDomainId() );
1797 cd0.addCombinableDomain( c.getDomainId() );
1798 cd0.addCombinableDomain( c.getDomainId() );
1799 cd0.addCombinableDomain( c.getDomainId() );
1800 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
1803 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
1806 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
1809 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
1812 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
1815 if ( cd0.getAllDomains().size() != 4 ) {
1818 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
1821 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
1824 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
1827 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
1830 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
1833 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "key0", "a" );
1834 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "key0" );
1835 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "key0", "c" );
1836 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "key0", "cc" );
1837 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "c", "key0" );
1838 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
1841 if ( !cd0.toBinaryDomainCombinations().contains( s1 ) ) {
1844 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
1847 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
1850 if ( !cd0.toBinaryDomainCombinations().contains( s4 ) ) {
1853 final Domain key1 = new BasicDomain( "key1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1854 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1855 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1856 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1857 final CombinableDomains cd1 = new BasicCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
1858 cd1.addCombinableDomain( a1.getDomainId() );
1859 cd1.addCombinableDomain( b1.getDomainId() );
1860 cd1.addCombinableDomain( c1.getDomainId() );
1861 cd1.addCombinableDomain( key1.getDomainId() );
1862 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
1865 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
1868 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
1871 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
1874 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
1877 if ( cd1.getAllDomains().size() != 4 ) {
1880 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
1883 final BasicBinaryDomainCombination kk = new BasicBinaryDomainCombination( "key1", "key1" );
1884 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
1888 catch ( final Exception e ) {
1889 e.printStackTrace( System.out );
1895 private static boolean testCombinationsBasedPairwiseSimilarityCalculator() {
1897 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1898 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1899 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1900 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1901 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1902 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1903 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1904 new BasicSpecies( "rabbit" ) );
1905 one.addCombinableDomain( a.getDomainId() );
1906 one.addCombinableDomain( a.getDomainId() );
1907 two.addCombinableDomain( new BasicDomain( "A", 1, 5, ( short ) 1, ( short ) 4, 0.1, -12 ).getDomainId() );
1908 two.addCombinableDomain( b.getDomainId() );
1909 two.addCombinableDomain( c.getDomainId() );
1910 final PairwiseDomainSimilarityCalculator calc = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1911 final PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1912 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 / ( 1 + 2 ) ) ) {
1915 if ( s1.getDifferenceInCounts() != ( 1 - 3 ) ) {
1918 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s1 ).getNumberOfDifferentDomains() != 2 ) {
1921 one.addCombinableDomain( b.getDomainId() );
1922 one.addCombinableDomain( c.getDomainId() );
1923 final PairwiseDomainSimilarity s2 = calc.calculateSimilarity( one, two );
1924 if ( !TestSurfacing.isEqual( s2.getSimilarityScore(), 3.0 / ( 0 + 3 ) ) ) {
1927 if ( s2.getDifferenceInCounts() != 0 ) {
1930 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s2 ).getNumberOfDifferentDomains() != 0 ) {
1933 final Domain d = new BasicDomain( "D", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1934 final Domain e = new BasicDomain( "E", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1935 final Domain f = new BasicDomain( "F", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1936 one.addCombinableDomain( d.getDomainId() );
1937 one.addCombinableDomain( d.getDomainId() );
1938 one.addCombinableDomain( e.getDomainId() );
1939 one.addCombinableDomain( f.getDomainId() );
1940 final PairwiseDomainSimilarity s3 = calc.calculateSimilarity( one, two );
1941 if ( !TestSurfacing.isEqual( s3.getSimilarityScore(), 3.0 / ( 3 + 3 ) ) ) {
1944 if ( s3.getDifferenceInCounts() != ( 6 - 3 ) ) {
1947 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s3 ).getNumberOfDifferentDomains() != 3 ) {
1950 final Domain aaa = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1951 final Domain bbb = new BasicDomain( "bbb", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1952 final Domain three_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1953 final Domain four_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1954 final CombinableDomains three = new BasicCombinableDomains( three_key.getDomainId(),
1955 new BasicSpecies( "mouse" ) );
1956 final CombinableDomains four = new BasicCombinableDomains( four_key.getDomainId(),
1957 new BasicSpecies( "rabbit" ) );
1958 three.addCombinableDomain( aaa.getDomainId() );
1959 four.addCombinableDomain( bbb.getDomainId() );
1960 final PairwiseDomainSimilarityCalculator calc2 = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1961 final PairwiseDomainSimilarity s4 = calc2.calculateSimilarity( three, four );
1962 if ( !TestSurfacing.isEqual( s4.getSimilarityScore(), 0.0 / ( 0 + 2 ) ) ) {
1965 final Domain aaa2 = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1966 four.addCombinableDomain( aaa2.getDomainId() );
1967 final PairwiseDomainSimilarity s5 = calc.calculateSimilarity( three, four );
1968 if ( !TestSurfacing.isEqual( s5.getSimilarityScore(), 1.0 / ( 1 + 1 ) ) ) {
1972 catch ( final Exception e ) {
1973 e.printStackTrace( System.out );
1979 private static boolean testCopyNumberBasedPairwiseSimilarityCalculator() {
1981 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1982 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1983 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1984 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1985 new BasicSpecies( "rabbit" ) );
1986 one.setKeyDomainCount( 2 );
1987 two.setKeyDomainCount( 3 );
1988 final PairwiseDomainSimilarityCalculator calc = new DomainCountsBasedPairwiseSimilarityCalculator();
1989 PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1990 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 3 - 2.0 ) / ( 2 + 3 ) ) ) {
1993 if ( s1.getDifferenceInCounts() != ( 2 - 3 ) ) {
1996 one.setKeyDomainCount( 1 );
1997 two.setKeyDomainCount( 1 );
1998 s1 = calc.calculateSimilarity( one, two );
1999 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 ) ) {
2002 if ( s1.getDifferenceInCounts() != ( 1 - 1 ) ) {
2005 one.setKeyDomainCount( 1 );
2006 two.setKeyDomainCount( 1000 );
2007 s1 = calc.calculateSimilarity( one, two );
2008 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - 999.0 / 1001 ) ) {
2011 if ( s1.getDifferenceInCounts() != ( 1 - 1000 ) ) {
2015 catch ( final Exception e ) {
2016 e.printStackTrace( System.out );
2022 private static boolean testDirectedCombinableDomains() {
2024 final Domain key0 = new BasicDomain( "key0", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 );
2025 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2026 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2027 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2028 final CombinableDomains cd0 = new DirectedCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
2029 cd0.addCombinableDomain( a.getDomainId() );
2030 cd0.addCombinableDomain( b.getDomainId() );
2031 cd0.addCombinableDomain( b.getDomainId() );
2032 cd0.addCombinableDomain( c.getDomainId() );
2033 cd0.addCombinableDomain( c.getDomainId() );
2034 cd0.addCombinableDomain( c.getDomainId() );
2035 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
2038 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
2041 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
2044 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
2047 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
2050 if ( cd0.getAllDomains().size() != 4 ) {
2053 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
2056 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
2059 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
2062 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
2065 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
2068 final BinaryDomainCombination s0 = new DirectedBinaryDomainCombination( "key0", "a" );
2069 final BinaryDomainCombination s1 = new DirectedBinaryDomainCombination( "b", "key0" );
2070 final BinaryDomainCombination s2 = new DirectedBinaryDomainCombination( "key0", "c" );
2071 final BinaryDomainCombination s3 = new DirectedBinaryDomainCombination( "key0", "cc" );
2072 final BinaryDomainCombination s4 = new DirectedBinaryDomainCombination( "a", "b" );
2073 final BinaryDomainCombination s5 = new DirectedBinaryDomainCombination( "b", "a" );
2074 final BinaryDomainCombination s6 = new DirectedBinaryDomainCombination( "key0", "b" );
2075 final BinaryDomainCombination s7 = new DirectedBinaryDomainCombination( "a", "key0" );
2076 final BinaryDomainCombination s8 = new DirectedBinaryDomainCombination( "c", "key0" );
2077 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
2080 if ( cd0.toBinaryDomainCombinations().contains( s1 ) ) {
2083 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
2086 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
2089 if ( cd0.toBinaryDomainCombinations().contains( s4 ) ) {
2092 if ( cd0.toBinaryDomainCombinations().contains( s5 ) ) {
2095 if ( !cd0.toBinaryDomainCombinations().contains( s6 ) ) {
2098 if ( cd0.toBinaryDomainCombinations().contains( s7 ) ) {
2101 if ( cd0.toBinaryDomainCombinations().contains( s8 ) ) {
2104 final Domain key1 = new BasicDomain( "key1", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 );
2105 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2106 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2107 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2108 final CombinableDomains cd1 = new DirectedCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
2109 cd1.addCombinableDomain( a1.getDomainId() );
2110 cd1.addCombinableDomain( b1.getDomainId() );
2111 cd1.addCombinableDomain( c1.getDomainId() );
2112 cd1.addCombinableDomain( key1.getDomainId() );
2113 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
2116 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
2119 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
2122 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
2125 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
2128 if ( cd1.getAllDomains().size() != 4 ) {
2131 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
2134 final BinaryDomainCombination kk = new DirectedBinaryDomainCombination( "key1", "key1" );
2135 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
2139 catch ( final Exception e ) {
2140 e.printStackTrace( System.out );
2146 private static boolean testDirectedness() {
2148 final BinaryStates X = BinaryStates.PRESENT;
2149 final BinaryStates O = BinaryStates.ABSENT;
2150 final GainLossStates G = GainLossStates.GAIN;
2151 final GainLossStates L = GainLossStates.LOSS;
2152 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
2153 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
2154 final Protein one_1 = new BasicProtein( "one", "1" );
2155 final Protein two_1 = new BasicProtein( "two", "1" );
2156 final Protein three_1 = new BasicProtein( "three", "1" );
2157 final Protein four_1 = new BasicProtein( "four", "1" );
2158 final Protein five_1 = new BasicProtein( "five", "1" );
2159 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2160 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2161 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2162 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2163 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2164 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2165 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2166 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2167 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2168 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2169 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2170 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2171 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2172 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2173 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2174 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2175 final List<Protein> list_1 = new ArrayList<Protein>();
2176 list_1.add( one_1 );
2177 list_1.add( two_1 );
2178 list_1.add( three_1 );
2179 list_1.add( four_1 );
2180 list_1.add( five_1 );
2181 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2182 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED );
2183 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "B" ) ) ) {
2186 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "A" ) ) ) {
2189 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "A" ) ) ) {
2192 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "C" ) ) ) {
2195 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "A" ) ) ) {
2198 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "C" ) ) ) {
2201 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "X" ) ) ) {
2204 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2207 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
2210 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2213 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2216 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "A" ) ) ) {
2219 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "B" ) ) ) {
2222 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2225 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2228 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2231 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
2234 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2237 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "N" ) ) ) {
2240 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "M" ) ) ) {
2243 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "P" ) ) ) {
2246 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "P" ) ) ) {
2249 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "N" ) ) ) {
2252 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "M" ) ) ) {
2255 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2258 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2261 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "B" ) ) ) {
2264 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
2265 // gwcd_list.add( gwcd_1 );
2266 // gwcd_list.add( gwcd_2 );
2267 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
2268 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
2269 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
2270 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
2271 // if ( matrix_d.getState( 0, 0 ) != X ) {
2274 // if ( matrix_bc.getState( 0, 0 ) != X ) {
2279 // final BasicCharacterStateMatrix<BinaryStates> dm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
2280 // { X, X, X, X, X, X }, { X, X, X, X, X, X } } );
2281 // if ( !matrix_d.equals( dm ) ) {
2284 // final BasicCharacterStateMatrix<BinaryStates> bcm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
2285 // { X, O, X, X, X, X, O, X, X, O, X, X }, { X, X, X, O, O, O, O, X, O, O, X, X } } );
2286 // if ( !matrix_d.equals( dm ) ) {
2289 //``````````````````````````
2290 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
2291 // gwcd_list.add( one );
2292 // gwcd_list.add( two );
2293 // gwcd_list.add( three );
2294 // gwcd_list.add( four );
2295 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimony
2296 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
2297 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimony
2298 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
2299 // // System.out.println( "d:" );
2300 // // System.out.println(matrix_d.toStringBuffer().toString() );
2301 // // System.out.println( "bc:" );
2302 // // System.out.println(matrix_bc.toStringBuffer().toString() );
2303 // // 1 a b c e f g h l m
2304 // // 2 a b c e f g i n o
2305 // // 3 a b d e f g j p q
2307 // if ( matrix_d.getState( 0, 0 ) != X ) {
2310 // if ( matrix_d.getState( 0, 1 ) != X ) {
2313 // if ( matrix_d.getState( 0, 2 ) != X ) {
2316 // if ( matrix_d.getState( 0, 3 ) != O ) {
2319 // if ( matrix_d.getState( 0, 4 ) != X ) {
2322 // if ( matrix_d.getState( 0, 5 ) != X ) {
2325 // if ( matrix_d.getState( 0, 6 ) != X ) {
2328 // if ( matrix_d.getState( 0, 7 ) != X ) {
2331 // if ( matrix_d.getState( 0, 8 ) != O ) {
2334 // // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
2335 // // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
2336 // // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
2338 // if ( matrix_bc.getState( 0, 0 ) != X ) {
2341 // if ( matrix_bc.getState( 0, 1 ) != X ) {
2344 // if ( matrix_bc.getState( 0, 2 ) != X ) {
2347 // if ( matrix_bc.getState( 0, 3 ) != O ) {
2350 // if ( matrix_bc.getState( 0, 4 ) != X ) {
2353 // if ( matrix_bc.getState( 1, 0 ) != O ) {
2356 // if ( matrix_bc.getState( 1, 1 ) != X ) {
2359 // if ( matrix_bc.getState( 1, 2 ) != X ) {
2362 // if ( matrix_bc.getState( 1, 3 ) != O ) {
2365 // if ( matrix_bc.getState( 1, 4 ) != X ) {
2368 // if ( matrix_bc.getState( 2, 0 ) != O ) {
2371 // if ( matrix_bc.getState( 2, 1 ) != X ) {
2374 // if ( matrix_bc.getState( 2, 2 ) != O ) {
2377 // if ( matrix_bc.getState( 2, 3 ) != X ) {
2380 // if ( matrix_bc.getState( 2, 4 ) != X ) {
2383 // final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
2384 // final String p0_str = "((one,two)1-2,(three,four)3-4)root";
2385 // final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
2386 // final DomainParsimony dp0 = DomainParsimony.createInstance( p0, gwcd_list );
2387 // dp0.executeDolloParsimonyOnDomainPresence();
2388 // final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
2389 // final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
2390 // dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2391 // final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
2392 // final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
2393 // if ( is_matrix_d.getState( "root", "A" ) != X ) {
2396 // if ( is_matrix_d.getState( "root", "B" ) != X ) {
2399 // if ( is_matrix_d.getState( "root", "C" ) != O ) {
2402 // if ( is_matrix_d.getState( "root", "D" ) != O ) {
2405 // if ( is_matrix_d.getState( "root", "E" ) != X ) {
2408 // if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
2411 // if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
2414 // if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
2417 // if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
2420 // if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
2423 // if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
2426 // if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
2429 // if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
2432 // if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
2435 // if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
2438 // if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
2441 // if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
2444 // if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
2447 // if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
2450 // final Protein ab_1 = new BasicProtein( "ab", "one" );
2451 // ab_1.addProteinDomain( a );
2452 // ab_1.addProteinDomain( b );
2453 // final Protein ac_1 = new BasicProtein( "ac", "one" );
2454 // ac_1.addProteinDomain( a );
2455 // ac_1.addProteinDomain( c );
2456 // final Protein de_1 = new BasicProtein( "de", "one" );
2457 // de_1.addProteinDomain( d );
2458 // de_1.addProteinDomain( e );
2459 // final Protein ac_2 = new BasicProtein( "ac", "two" );
2460 // ac_2.addProteinDomain( a );
2461 // ac_2.addProteinDomain( c );
2462 // final Protein ab_3 = new BasicProtein( "ab", "three" );
2463 // ab_3.addProteinDomain( a );
2464 // ab_3.addProteinDomain( b );
2465 // final Protein de_4 = new BasicProtein( "de", "four" );
2466 // de_4.addProteinDomain( d );
2467 // de_4.addProteinDomain( e );
2468 // final Protein ab_6 = new BasicProtein( "ab", "six" );
2469 // ab_6.addProteinDomain( a );
2470 // ab_6.addProteinDomain( b );
2471 // final List<Protein> spec_one = new ArrayList<Protein>();
2472 // final List<Protein> spec_two = new ArrayList<Protein>();
2473 // final List<Protein> spec_three = new ArrayList<Protein>();
2474 // final List<Protein> spec_four = new ArrayList<Protein>();
2475 // final List<Protein> spec_five = new ArrayList<Protein>();
2476 // final List<Protein> spec_six = new ArrayList<Protein>();
2477 // final List<Protein> spec_seven = new ArrayList<Protein>();
2478 // spec_one.add( ab_1 );
2479 // spec_one.add( ac_1 );
2480 // spec_one.add( de_1 );
2481 // spec_two.add( ac_2 );
2482 // spec_three.add( ab_3 );
2483 // spec_four.add( de_4 );
2484 // spec_six.add( ab_6 );
2485 // final GenomeWideCombinableDomains one_gwcd = BasicGenomeWideCombinableDomains
2486 // .createInstance( spec_one, false, new BasicSpecies( "one" ), false );
2487 // final GenomeWideCombinableDomains two_gwcd = BasicGenomeWideCombinableDomains
2488 // .createInstance( spec_two, false, new BasicSpecies( "two" ), false );
2489 // final GenomeWideCombinableDomains three_gwcd = BasicGenomeWideCombinableDomains
2490 // .createInstance( spec_three, false, new BasicSpecies( "three" ), false );
2491 // final GenomeWideCombinableDomains four_gwcd = BasicGenomeWideCombinableDomains
2492 // .createInstance( spec_four, false, new BasicSpecies( "four" ), false );
2493 // final GenomeWideCombinableDomains five_gwcd = BasicGenomeWideCombinableDomains
2494 // .createInstance( spec_five, false, new BasicSpecies( "five" ), false );
2495 // final GenomeWideCombinableDomains six_gwcd = BasicGenomeWideCombinableDomains
2496 // .createInstance( spec_six, false, new BasicSpecies( "six" ), false );
2497 // final GenomeWideCombinableDomains seven_gwcd = BasicGenomeWideCombinableDomains
2498 // .createInstance( spec_seven, false, new BasicSpecies( "seven" ), false
2500 // final List<GenomeWideCombinableDomains> gwcd_list1 = new ArrayList<GenomeWideCombinableDomains>();
2501 // gwcd_list1.add( one_gwcd );
2502 // gwcd_list1.add( two_gwcd );
2503 // gwcd_list1.add( three_gwcd );
2504 // gwcd_list1.add( four_gwcd );
2505 // gwcd_list1.add( five_gwcd );
2506 // gwcd_list1.add( six_gwcd );
2507 // gwcd_list1.add( seven_gwcd );
2508 // final PhylogenyFactory factory1 = ParserBasedPhylogenyFactory.getInstance();
2509 // final String p1_str = "(((((one,two)12,three)123,(four,five)45)12345,six)123456,seven)root";
2510 // final Phylogeny p1 = factory1.create( p1_str, new NHXParser() )[ 0 ];
2511 // final DomainParsimony dp1 = DomainParsimony.createInstance( p1, gwcd_list1 );
2512 // dp1.executeDolloParsimonyOnDomainPresence();
2513 // final CharacterStateMatrix<GainLossStates> gl_dollo_d = dp1.getGainLossMatrix();
2514 // final CharacterStateMatrix<BinaryStates> i_dollo_d = dp1.getInternalStatesMatrix();
2515 // if ( dp1.getCost() != 14 ) {
2518 // if ( dp1.getTotalGains() != 5 ) {
2521 // if ( dp1.getTotalLosses() != 9 ) {
2524 // if ( dp1.getTotalUnchanged() != 51 ) {
2527 // if ( dp1.getNetGainsOnNode( "45" ) != -2 ) {
2530 // if ( dp1.getSumOfGainsOnNode( "45" ) != 0 ) {
2533 // if ( dp1.getSumOfLossesOnNode( "45" ) != 2 ) {
2536 // if ( dp1.getSumOfUnchangedOnNode( "45" ) != 3 ) {
2539 // if ( dp1.getSumOfUnchangedPresentOnNode( "45" ) != 2 ) {
2542 // if ( dp1.getSumOfUnchangedAbsentOnNode( "45" ) != 1 ) {
2545 // if ( dp1.getUnitsGainedOnNode( "45" ).contains( "A" ) ) {
2548 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A" ) ) {
2551 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "B" ) ) {
2554 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D" ) ) {
2557 // if ( !dp1.getUnitsOnNode( "12" ).contains( "A" ) ) {
2560 // if ( !dp1.getUnitsOnNode( "12" ).contains( "B" ) ) {
2563 // if ( !dp1.getUnitsOnNode( "12" ).contains( "C" ) ) {
2566 // if ( !dp1.getUnitsOnNode( "12" ).contains( "D" ) ) {
2569 // if ( !dp1.getUnitsOnNode( "12" ).contains( "E" ) ) {
2572 // if ( dp1.getNetGainsOnNode( "123456" ) != 2 ) {
2575 // if ( dp1.getSumOfGainsOnNode( "123456" ) != 2 ) {
2578 // dp1.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2579 // final CharacterStateMatrix<GainLossStates> gl_dollo_bc = dp1.getGainLossMatrix();
2580 // final CharacterStateMatrix<BinaryStates> i_dollo_bc = dp1.getInternalStatesMatrix();
2581 // if ( dp1.getCost() != 8 ) {
2584 // if ( dp1.getTotalGains() != 3 ) {
2587 // if ( dp1.getTotalLosses() != 5 ) {
2590 // if ( dp1.getTotalUnchanged() != 31 ) {
2593 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2596 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D=E" ) ) {
2599 // dp1.executeFitchParsimonyOnDomainPresence();
2600 // final CharacterStateMatrix<GainLossStates> gl_fitch_d = dp1.getGainLossMatrix();
2601 // final CharacterStateMatrix<BinaryStates> i_fitch_d = dp1.getInternalStatesMatrix();
2602 // if ( dp1.getCost() != 10 ) {
2605 // if ( dp1.getTotalGains() != 7 ) {
2608 // if ( dp1.getTotalLosses() != 3 ) {
2611 // if ( dp1.getTotalUnchanged() != 55 ) {
2614 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "E" ) ) {
2617 // dp1.executeFitchParsimonyOnBinaryDomainCombintion();
2618 // final CharacterStateMatrix<GainLossStates> gl_fitch_bc = dp1.getGainLossMatrix();
2619 // final CharacterStateMatrix<BinaryStates> i_fitch_bc = dp1.getInternalStatesMatrix();
2620 // if ( dp1.getCost() != 6 ) {
2623 // if ( dp1.getTotalGains() != 4 ) {
2626 // if ( dp1.getTotalLosses() != 2 ) {
2629 // if ( dp1.getTotalUnchanged() != 33 ) {
2632 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2635 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "D=E" ) ) {
2638 // if ( dp1.getNetGainsOnNode( "two" ) != -1 ) {
2641 // if ( dp1.getNetGainsOnNode( "123" ) != 0 ) {
2644 // if ( dp1.getSumOfUnchangedPresentOnNode( "123" ) != 1 ) {
2647 // if ( dp1.getSumOfUnchangedAbsentOnNode( "123" ) != 2 ) {
2650 // if ( dp1.getSumOfUnchangedOnNode( "123" ) != 3 ) {
2653 // if ( dp1.getSumOfUnchangedOnNode( "two" ) != 2 ) {
2656 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "two" ).contains( "D=E" ) ) {
2659 // if ( !dp1.getUnitsUnchangedPresentOnNode( "two" ).contains( "A=C" ) ) {
2662 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "A=C" ) ) {
2665 // if ( !dp1.getUnitsUnchangedPresentOnNode( "123" ).contains( "A=B" ) ) {
2668 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "D=E" ) ) {
2671 // CharacterStateMatrix<BinaryStates> bsm = null;
2672 // CharacterStateMatrix<GainLossStates> glm = null;
2673 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, X, X },
2674 // { X, X, O, X, X }, { O, O, O, X, X }, { X, X, O, X, X }, { X, X, O, O, O }, { O, O, O, O, O } } );
2675 // if ( !bsm.equals( i_dollo_d ) ) {
2678 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, O, O },
2679 // { X, X, O, O, O }, { O, O, O, O, O }, { X, X, O, O, O }, { X, X, O, O, O }, { O, O, O, O, O } } );
2680 // if ( !bsm.equals( i_fitch_d ) ) {
2683 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, P, P },
2684 // { P, L, P, L, L }, { P, P, G, P, P }, { P, P, A, L, L }, { P, P, A, P, P }, { A, A, A, P, P },
2685 // { A, A, A, L, L }, { L, L, A, P, P }, { P, P, A, G, G }, { P, P, A, A, A }, { G, G, A, A, A },
2686 // { A, A, A, A, A }, { A, A, A, A, A } } );
2687 // if ( !glm.equals( gl_dollo_d ) ) {
2690 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, G, G },
2691 // { P, L, P, A, A }, { P, P, G, A, A }, { P, P, A, A, A }, { P, P, A, A, A }, { A, A, A, G, G },
2692 // { A, A, A, A, A }, { L, L, A, A, A }, { P, P, A, A, A }, { P, P, A, A, A }, { G, G, A, A, A },
2693 // { A, A, A, A, A }, { A, A, A, A, A } } );
2694 // if ( !glm.equals( gl_fitch_d ) ) {
2697 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X }, { X, O, X },
2698 // { O, O, X }, { X, O, X }, { X, O, O }, { O, O, O } } );
2699 // if ( !bsm.equals( i_dollo_bc ) ) {
2702 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, O }, { X, O, O },
2703 // { O, O, O }, { X, O, O }, { X, O, O }, { O, O, O } } );
2704 // if ( !bsm.equals( i_fitch_bc ) ) {
2707 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P }, { L, P, L },
2708 // { P, G, P }, { P, A, L }, { P, A, P }, { A, A, P }, { A, A, L }, { L, A, P }, { P, A, G },
2709 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2710 // if ( !glm.equals( gl_dollo_bc ) ) {
2713 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, G }, { L, P, A },
2714 // { P, G, A }, { P, A, A }, { P, A, A }, { A, A, G }, { A, A, A }, { L, A, A }, { P, A, A },
2715 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2716 // if ( !glm.equals( gl_fitch_bc ) ) {
2720 catch ( final Exception e ) {
2721 e.printStackTrace( System.out );
2727 private static boolean testDirectednessAndAdjacency() {
2729 final Protein one_1 = new BasicProtein( "one", "1" );
2730 final Protein two_1 = new BasicProtein( "two", "1" );
2731 final Protein three_1 = new BasicProtein( "three", "1" );
2732 final Protein four_1 = new BasicProtein( "four", "1" );
2733 final Protein five_1 = new BasicProtein( "five", "1" );
2734 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2735 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2736 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2737 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2738 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2739 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2740 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2741 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2742 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2743 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2744 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2745 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2746 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2747 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2748 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2749 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2750 final List<Protein> list_1 = new ArrayList<Protein>();
2751 list_1.add( one_1 );
2752 list_1.add( two_1 );
2753 list_1.add( three_1 );
2754 list_1.add( four_1 );
2755 list_1.add( five_1 );
2756 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2757 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED_ADJACTANT );
2758 if ( !gwcd_1.toBinaryDomainCombinations()
2759 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "B" ) ) ) {
2762 if ( gwcd_1.toBinaryDomainCombinations()
2763 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "A" ) ) ) {
2766 if ( gwcd_1.toBinaryDomainCombinations()
2767 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "A" ) ) ) {
2770 if ( gwcd_1.toBinaryDomainCombinations()
2771 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "C" ) ) ) {
2774 if ( gwcd_1.toBinaryDomainCombinations()
2775 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "A" ) ) ) {
2778 if ( !gwcd_1.toBinaryDomainCombinations()
2779 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "C" ) ) ) {
2782 if ( !gwcd_1.toBinaryDomainCombinations()
2783 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "X" ) ) ) {
2786 if ( gwcd_1.toBinaryDomainCombinations()
2787 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2790 if ( !gwcd_1.toBinaryDomainCombinations()
2791 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2794 if ( gwcd_1.toBinaryDomainCombinations()
2795 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2798 if ( gwcd_1.toBinaryDomainCombinations()
2799 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2802 if ( !gwcd_1.toBinaryDomainCombinations()
2803 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2806 if ( gwcd_1.toBinaryDomainCombinations()
2807 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "A" ) ) ) {
2810 if ( gwcd_1.toBinaryDomainCombinations()
2811 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "B" ) ) ) {
2814 if ( !gwcd_1.toBinaryDomainCombinations()
2815 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2818 if ( gwcd_1.toBinaryDomainCombinations()
2819 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2822 if ( gwcd_1.toBinaryDomainCombinations()
2823 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2826 if ( gwcd_1.toBinaryDomainCombinations()
2827 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2830 if ( gwcd_1.toBinaryDomainCombinations()
2831 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2834 if ( !gwcd_1.toBinaryDomainCombinations()
2835 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "N" ) ) ) {
2838 if ( !gwcd_1.toBinaryDomainCombinations()
2839 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "M" ) ) ) {
2842 if ( !gwcd_1.toBinaryDomainCombinations()
2843 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "P" ) ) ) {
2846 if ( gwcd_1.toBinaryDomainCombinations()
2847 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "P" ) ) ) {
2850 if ( gwcd_1.toBinaryDomainCombinations()
2851 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "N" ) ) ) {
2854 if ( gwcd_1.toBinaryDomainCombinations()
2855 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "M" ) ) ) {
2858 if ( gwcd_1.toBinaryDomainCombinations()
2859 .contains( new AdjactantDirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2862 if ( gwcd_1.toBinaryDomainCombinations()
2863 .contains( new AdjactantDirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2866 if ( gwcd_1.toBinaryDomainCombinations()
2867 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "B" ) ) ) {
2871 catch ( final Exception e ) {
2872 e.printStackTrace( System.out );
2878 private static boolean testDomainArchitectureBasedGenomeSimilarityCalculator() {
2880 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2881 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2882 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2883 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2884 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2885 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2886 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2887 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2888 final Domain i = new BasicDomain( "i", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2889 final Domain j = new BasicDomain( "j", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2890 final Domain k = new BasicDomain( "k", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2891 final Domain l = new BasicDomain( "l", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2892 final Domain m = new BasicDomain( "m", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2893 final Domain n = new BasicDomain( "n", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2894 final Protein eel_0 = new BasicProtein( "0", "eel" );
2895 final Protein eel_1 = new BasicProtein( "1", "eel" );
2896 final Protein eel_2 = new BasicProtein( "2", "eel" );
2897 final Protein eel_3 = new BasicProtein( "3", "eel" );
2898 final Protein eel_4 = new BasicProtein( "4", "eel" );
2899 final Protein eel_5 = new BasicProtein( "5", "eel" );
2900 final Protein eel_6 = new BasicProtein( "6", "eel" );
2901 final Protein rat_0 = new BasicProtein( "0", "rat" );
2902 final Protein rat_1 = new BasicProtein( "1", "rat" );
2903 final Protein rat_2 = new BasicProtein( "2", "rat" );
2904 final Protein rat_3 = new BasicProtein( "3", "rat" );
2905 final Protein rat_4 = new BasicProtein( "4", "rat" );
2906 final Protein rat_5 = new BasicProtein( "5", "rat" );
2907 final Protein rat_6 = new BasicProtein( "6", "rat" );
2908 final Protein rat_7 = new BasicProtein( "7", "rat" );
2909 eel_1.addProteinDomain( a );
2910 eel_2.addProteinDomain( a );
2911 eel_2.addProteinDomain( b );
2912 eel_3.addProteinDomain( a );
2913 eel_3.addProteinDomain( a );
2914 eel_3.addProteinDomain( b );
2915 eel_4.addProteinDomain( a );
2916 eel_4.addProteinDomain( b );
2917 eel_4.addProteinDomain( c );
2918 eel_4.addProteinDomain( d );
2919 eel_4.addProteinDomain( e );
2920 eel_5.addProteinDomain( e );
2921 eel_5.addProteinDomain( e );
2922 eel_5.addProteinDomain( f );
2923 eel_5.addProteinDomain( f );
2924 eel_5.addProteinDomain( f );
2925 eel_5.addProteinDomain( f );
2926 eel_6.addProteinDomain( g );
2927 eel_6.addProteinDomain( h );
2928 rat_1.addProteinDomain( a );
2929 rat_2.addProteinDomain( a );
2930 rat_2.addProteinDomain( b );
2931 rat_3.addProteinDomain( a );
2932 rat_3.addProteinDomain( a );
2933 rat_3.addProteinDomain( b );
2934 rat_4.addProteinDomain( a );
2935 rat_4.addProteinDomain( b );
2936 rat_4.addProteinDomain( c );
2937 rat_4.addProteinDomain( i );
2938 rat_4.addProteinDomain( l );
2939 rat_5.addProteinDomain( i );
2940 rat_5.addProteinDomain( f );
2941 rat_5.addProteinDomain( f );
2942 rat_6.addProteinDomain( j );
2943 rat_6.addProteinDomain( k );
2944 rat_7.addProteinDomain( m );
2945 rat_7.addProteinDomain( n );
2946 final List<Protein> protein_list_eel = new ArrayList<Protein>();
2947 protein_list_eel.add( eel_0 );
2948 protein_list_eel.add( eel_1 );
2949 protein_list_eel.add( eel_2 );
2950 protein_list_eel.add( eel_3 );
2951 protein_list_eel.add( eel_4 );
2952 protein_list_eel.add( eel_5 );
2953 protein_list_eel.add( eel_6 );
2954 final List<Protein> protein_list_rat = new ArrayList<Protein>();
2955 protein_list_rat.add( rat_0 );
2956 protein_list_rat.add( rat_1 );
2957 protein_list_rat.add( rat_2 );
2958 protein_list_rat.add( rat_3 );
2959 protein_list_rat.add( rat_4 );
2960 protein_list_rat.add( rat_5 );
2961 protein_list_rat.add( rat_6 );
2962 protein_list_rat.add( rat_7 );
2963 final GenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
2964 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
2965 final GenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
2966 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
2967 final GenomeWideCombinableDomains rat_not_ignore = BasicGenomeWideCombinableDomains
2968 .createInstance( protein_list_rat, false, new BasicSpecies( "rat" ) );
2969 final GenomeWideCombinableDomains rat_ignore = BasicGenomeWideCombinableDomains
2970 .createInstance( protein_list_rat, true, new BasicSpecies( "rat" ) );
2971 final DomainArchitectureBasedGenomeSimilarityCalculator calc_ni = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_not_ignore,
2973 final DomainArchitectureBasedGenomeSimilarityCalculator calc_i = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_ignore,
2975 if ( calc_ni.getAllDomains().size() != 14 ) {
2978 if ( calc_i.getAllDomains().size() != 14 ) {
2981 if ( calc_ni.getDomainsSpecificToGenome0().size() != 4 ) {
2984 if ( calc_i.getDomainsSpecificToGenome0().size() != 4 ) {
2987 if ( calc_ni.getDomainsSpecificToGenome1().size() != 6 ) {
2990 if ( calc_i.getDomainsSpecificToGenome1().size() != 6 ) {
2993 if ( calc_i.getSharedDomains().size() != 4 ) {
2996 if ( calc_ni.getSharedDomains().size() != 4 ) {
2999 if ( !calc_ni.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
3002 if ( !calc_ni.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
3005 if ( !calc_ni.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
3008 if ( !calc_ni.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
3011 if ( calc_ni.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
3014 if ( calc_ni.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
3017 if ( !calc_i.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
3020 if ( !calc_i.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
3023 if ( !calc_i.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
3026 if ( !calc_i.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
3029 if ( calc_i.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
3032 if ( calc_i.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
3035 if ( !calc_ni.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
3038 if ( !calc_ni.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
3041 if ( !calc_ni.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
3044 if ( !calc_ni.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
3047 if ( !calc_ni.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
3050 if ( !calc_ni.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
3053 if ( calc_ni.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
3056 if ( calc_ni.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
3059 if ( calc_ni.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
3062 if ( !calc_i.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
3065 if ( !calc_i.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
3068 if ( !calc_i.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
3071 if ( !calc_i.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
3074 if ( !calc_i.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
3077 if ( !calc_i.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
3080 if ( calc_i.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
3083 if ( calc_i.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
3086 if ( calc_i.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
3089 if ( !calc_i.getSharedDomains().contains( a.getDomainId() ) ) {
3092 if ( !calc_i.getSharedDomains().contains( b.getDomainId() ) ) {
3095 if ( !calc_i.getSharedDomains().contains( c.getDomainId() ) ) {
3098 if ( !calc_i.getSharedDomains().contains( f.getDomainId() ) ) {
3101 final Set<DomainId> all = calc_ni.getAllDomains();
3102 if ( !all.contains( a.getDomainId() ) ) {
3105 if ( !all.contains( b.getDomainId() ) ) {
3108 if ( !all.contains( c.getDomainId() ) ) {
3111 if ( !all.contains( d.getDomainId() ) ) {
3114 if ( !all.contains( e.getDomainId() ) ) {
3117 if ( !all.contains( f.getDomainId() ) ) {
3120 if ( !all.contains( g.getDomainId() ) ) {
3123 if ( !all.contains( h.getDomainId() ) ) {
3126 if ( !all.contains( i.getDomainId() ) ) {
3129 if ( !all.contains( l.getDomainId() ) ) {
3132 if ( !all.contains( j.getDomainId() ) ) {
3135 if ( !all.contains( k.getDomainId() ) ) {
3138 if ( !all.contains( m.getDomainId() ) ) {
3141 if ( !all.contains( n.getDomainId() ) ) {
3144 final Set<BinaryDomainCombination> s_0_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome0();
3145 final Set<BinaryDomainCombination> s_0_i = calc_i.getBinaryDomainCombinationsSpecificToGenome0();
3146 final Set<BinaryDomainCombination> s_1_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome1();
3147 final Set<BinaryDomainCombination> s_1_i = calc_i.getBinaryDomainCombinationsSpecificToGenome1();
3148 final Set<BinaryDomainCombination> a_ni = calc_ni.getAllBinaryDomainCombinations();
3149 final Set<BinaryDomainCombination> a_i = calc_i.getAllBinaryDomainCombinations();
3150 final Set<BinaryDomainCombination> shared_ni = calc_ni.getSharedBinaryDomainCombinations();
3151 final Set<BinaryDomainCombination> shared_i = calc_i.getSharedBinaryDomainCombinations();
3152 if ( a_ni.size() != 25 ) {
3155 if ( a_i.size() != 22 ) {
3158 if ( s_0_ni.size() != 10 ) {
3161 if ( s_0_i.size() != 9 ) {
3164 if ( s_1_ni.size() != 10 ) {
3167 if ( s_1_i.size() != 10 ) {
3170 if ( shared_ni.size() != 5 ) {
3173 if ( shared_i.size() != 3 ) {
3176 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3179 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
3182 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3185 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3188 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3191 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3194 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3197 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3200 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3203 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3206 if ( !a_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3209 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3212 if ( !a_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3215 if ( !a_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3218 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3221 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3224 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3227 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3230 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3233 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3236 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3239 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "l" ) ) ) {
3242 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3245 if ( !a_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3248 if ( !a_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3251 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
3254 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "m" ) ) ) {
3257 if ( a_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3260 if ( a_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3263 if ( a_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3266 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3269 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3272 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3275 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3278 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3281 if ( shared_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3284 if ( shared_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3287 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3290 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3293 if ( !shared_i.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3296 if ( shared_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3299 if ( shared_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3302 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3305 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3308 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3311 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3314 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3317 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3320 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3323 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3326 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3329 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3332 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3335 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3338 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3341 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3344 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3347 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3350 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3353 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3356 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3359 if ( s_0_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3362 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3365 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3368 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3371 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3374 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3377 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3380 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3383 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3386 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3389 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3392 if ( s_1_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3395 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3398 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3401 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3404 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3407 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3410 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3413 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3416 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3419 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3422 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3425 if ( s_1_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3428 if ( !isEqual( calc_ni.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3429 1.0 - ( 25.0 - 5.0 ) / 25.0 ) ) {
3432 if ( !isEqual( calc_i.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3433 1.0 - ( 22.0 - 3.0 ) / 22.0 ) ) {
3436 if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
3439 if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
3442 final Domain u = new BasicDomain( "u", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3443 final Domain v = new BasicDomain( "v", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3444 final Domain w = new BasicDomain( "w", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3445 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3446 final Domain y = new BasicDomain( "y", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3447 final Domain z = new BasicDomain( "z", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3448 final Protein a_0 = new BasicProtein( "0", "a" );
3449 final Protein a_1 = new BasicProtein( "1", "a" );
3450 final Protein a_2 = new BasicProtein( "2", "a" );
3451 final Protein b_0 = new BasicProtein( "0", "b" );
3452 final Protein b_1 = new BasicProtein( "1", "b" );
3453 a_0.addProteinDomain( u );
3454 a_0.addProteinDomain( v );
3455 a_0.addProteinDomain( w );
3456 a_1.addProteinDomain( w );
3457 a_1.addProteinDomain( x );
3458 a_2.addProteinDomain( y );
3459 a_2.addProteinDomain( z );
3460 b_0.addProteinDomain( u );
3461 b_0.addProteinDomain( w );
3462 b_1.addProteinDomain( y );
3463 b_1.addProteinDomain( z );
3464 final List<Protein> protein_list_a = new ArrayList<Protein>();
3465 protein_list_a.add( a_0 );
3466 protein_list_a.add( a_1 );
3467 protein_list_a.add( a_2 );
3468 final List<Protein> protein_list_b = new ArrayList<Protein>();
3469 protein_list_b.add( b_0 );
3470 protein_list_b.add( b_1 );
3471 final GenomeWideCombinableDomains ca = BasicGenomeWideCombinableDomains
3472 .createInstance( protein_list_a, false, new BasicSpecies( "a" ) );
3473 final GenomeWideCombinableDomains cb = BasicGenomeWideCombinableDomains
3474 .createInstance( protein_list_b, true, new BasicSpecies( "b" ) );
3475 final DomainArchitectureBasedGenomeSimilarityCalculator calc_u = new DomainArchitectureBasedGenomeSimilarityCalculator( ca,
3477 calc_u.setAllowDomainsToBeIgnored( true );
3478 if ( calc_u.getAllDomains().size() != 6 ) {
3481 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3484 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3487 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3490 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3493 if ( calc_u.getSharedDomains().size() != 4 ) {
3496 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3499 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3502 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3505 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3508 if ( calc_u.getAllDomains().size() != 6 ) {
3511 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3514 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3517 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3520 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3523 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3526 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3529 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 3 ) {
3532 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3535 if ( calc_u.getSharedBinaryDomainCombinations().size() != 2 ) {
3538 if ( calc_u.getAllBinaryDomainCombinations().size() != 5 ) {
3541 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3542 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3545 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3546 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3549 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3550 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3553 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3556 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3559 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3562 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3565 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3568 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3571 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3574 calc_u.setAllowDomainsToBeIgnored( true );
3575 calc_u.addDomainIdToIgnore( u.getDomainId() );
3576 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3577 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3578 if ( calc_u.getAllDomains().size() != 5 ) {
3581 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3584 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3587 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3590 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3593 if ( calc_u.getSharedDomains().size() != 3 ) {
3596 if ( calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3599 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3602 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3605 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3608 if ( calc_u.getAllDomains().size() != 5 ) {
3611 if ( calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3614 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3617 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3620 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3623 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3626 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3629 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 2 ) {
3632 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3635 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3638 if ( calc_u.getAllBinaryDomainCombinations().size() != 3 ) {
3641 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3642 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3645 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3646 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3649 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3650 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3653 if ( calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3656 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3659 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3662 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3665 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3668 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3671 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3674 calc_u.setAllowDomainsToBeIgnored( false );
3675 if ( calc_u.getAllDomains().size() != 6 ) {
3679 calc_u.setAllowDomainsToBeIgnored( true );
3680 calc_u.deleteAllDomainIdsToIgnore();
3681 calc_u.addDomainIdToIgnore( new DomainId( "v" ) );
3682 calc_u.addDomainIdToIgnore( new DomainId( "w" ) );
3683 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3684 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3685 if ( calc_u.getAllDomains().size() != 4 ) {
3688 if ( calc_u.getDomainsSpecificToGenome0().size() != 1 ) {
3691 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3694 if ( calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3697 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3700 if ( calc_u.getSharedDomains().size() != 3 ) {
3703 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3706 if ( calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3709 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3712 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3715 if ( calc_u.getAllDomains().size() != 4 ) {
3718 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3721 if ( calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3724 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3727 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3730 if ( calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3733 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3736 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 0 ) {
3739 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3742 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3745 if ( calc_u.getAllBinaryDomainCombinations().size() != 1 ) {
3748 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "y", "z" ) ) ) {
3751 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3754 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3755 1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
3758 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
3761 calc_u.setAllowDomainsToBeIgnored( false );
3762 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3763 1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
3766 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
3769 calc_u.setAllowDomainsToBeIgnored( true );
3770 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3771 1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
3774 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
3777 calc_u.deleteAllDomainIdsToIgnore();
3778 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3779 1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
3782 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
3786 catch ( final Exception e ) {
3787 e.printStackTrace( System.out );
3793 private static boolean testDomainCombinationCounting( final File test_dir ) {
3795 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
3796 + ForesterUtil.getFileSeparator() + "hmmpfam_output2" ), "human", "ls" );
3797 parser.setEValueMaximum( 0.2 );
3798 parser.setIgnoreDufs( true );
3799 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
3800 final List<Protein> domain_collections = parser.parse();
3801 final BasicGenomeWideCombinableDomains cdcc = BasicGenomeWideCombinableDomains
3802 .createInstance( domain_collections, false, new BasicSpecies( "human" ) );
3803 CombinableDomains cd = cdcc.get( new DomainId( "A" ) );
3804 if ( cd.getKeyDomainCount() != 9 ) {
3807 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3810 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3813 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 2 ) {
3816 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
3819 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3822 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3825 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3828 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3831 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3834 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3837 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3840 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3843 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3846 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3849 if ( cd.getKeyDomainCount() != 9 ) {
3852 cd = cdcc.get( new DomainId( "B" ) );
3853 if ( cd.getKeyDomainCount() != 12 ) {
3856 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3859 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3862 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 6 ) {
3865 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3868 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3871 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3874 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3877 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3880 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3883 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3886 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3889 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3892 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3895 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3898 if ( cd.getKeyDomainCount() != 12 ) {
3901 cd = cdcc.get( new DomainId( "C" ) );
3902 if ( cd.getKeyDomainCount() != 10 ) {
3905 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3908 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3911 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 4 ) {
3914 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3917 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 2 ) {
3920 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3923 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3926 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3929 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3932 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3935 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 2 ) {
3938 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 2 ) {
3941 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 2 ) {
3944 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3947 cd = cdcc.get( new DomainId( "D" ) );
3948 if ( cd.getKeyDomainCount() != 15 ) {
3951 if ( cd.getKeyDomainProteinsCount() != 6 ) {
3954 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3957 cd = cdcc.get( new DomainId( "E" ) );
3958 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3961 if ( cd.getKeyDomainCount() != 1 ) {
3964 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3967 cd = cdcc.get( new DomainId( "U" ) );
3968 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3971 if ( cd.getKeyDomainCount() != 6 ) {
3974 if ( cd.getKeyDomainProteinsCount() != 3 ) {
3977 cd = cdcc.get( new DomainId( "V" ) );
3978 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3981 if ( cd.getKeyDomainCount() != 3 ) {
3984 if ( cd.getKeyDomainProteinsCount() != 2 ) {
3987 cd = cdcc.get( new DomainId( "W" ) );
3988 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3991 if ( cd.getKeyDomainCount() != 2 ) {
3994 if ( cd.getKeyDomainProteinsCount() != 2 ) {
3997 cd = cdcc.get( new DomainId( "X" ) );
3998 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4001 if ( cd.getKeyDomainCount() != 2 ) {
4004 cd = cdcc.get( new DomainId( "Y" ) );
4005 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4008 cd = cdcc.get( new DomainId( "Z" ) );
4009 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4012 cd = cdcc.get( new DomainId( "NN" ) );
4013 if ( cd.getKeyDomainCount() != 1 ) {
4016 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4019 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4022 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
4025 cd = cdcc.get( new DomainId( "MM" ) );
4026 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4029 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 0 ) {
4032 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
4035 cd = cdcc.get( new DomainId( "OO" ) );
4036 if ( cd.getNumberOfCombinableDomains() != 2 ) {
4039 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
4042 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 1 ) {
4045 cd = cdcc.get( new DomainId( "QQ" ) );
4046 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4049 if ( cd.getKeyDomainCount() != 17 ) {
4052 if ( cd.getKeyDomainProteinsCount() != 4 ) {
4055 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "QQ" ).getDomainId() ) != 3 ) {
4058 cd = cdcc.get( new DomainId( "PP" ) );
4059 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4062 if ( cd.getKeyDomainCount() != 2 ) {
4065 if ( cd.getKeyDomainProteinsCount() != 2 ) {
4068 cd = cdcc.get( new DomainId( "singlet" ) );
4069 if ( cd.getKeyDomainCount() != 1 ) {
4072 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4075 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4078 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "singlet" ).getDomainId() ) != 0 ) {
4081 cd = cdcc.get( new DomainId( "three" ) );
4082 if ( cd.getKeyDomainCount() != 3 ) {
4085 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4088 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4091 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 1 ) {
4094 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
4097 // Ignore combinations with same:
4098 final BasicGenomeWideCombinableDomains cdcc2 = BasicGenomeWideCombinableDomains
4099 .createInstance( domain_collections,
4101 new BasicSpecies( "human" ),
4103 DomainCombinationType.BASIC );
4104 cd = cdcc2.get( new DomainId( "A" ) );
4105 if ( cd.getKeyDomainCount() != 9 ) {
4108 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4111 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4114 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 0 ) {
4117 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
4120 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
4123 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
4126 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
4129 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4132 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4135 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4138 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
4141 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
4144 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
4147 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4150 cd = cdcc2.get( new DomainId( "B" ) );
4151 if ( cd.getKeyDomainCount() != 12 ) {
4154 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4157 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4160 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 6 ) {
4163 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 0 ) {
4166 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 4 ) {
4169 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
4172 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
4175 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4178 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4181 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4184 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
4187 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
4190 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
4193 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4196 cd = cdcc2.get( new DomainId( "C" ) );
4197 if ( cd.getKeyDomainCount() != 10 ) {
4200 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4203 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4206 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 4 ) {
4209 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 4 ) {
4212 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 0 ) {
4215 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
4218 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
4221 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4224 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4227 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4230 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 2 ) {
4233 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 2 ) {
4236 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 2 ) {
4239 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4242 cd = cdcc2.get( new DomainId( "D" ) );
4243 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4246 cd = cdcc2.get( new DomainId( "E" ) );
4247 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4250 if ( cd.getKeyDomainCount() != 1 ) {
4253 cd = cdcc2.get( new DomainId( "U" ) );
4254 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4257 cd = cdcc2.get( new DomainId( "V" ) );
4258 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4261 cd = cdcc2.get( new DomainId( "W" ) );
4262 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4265 cd = cdcc2.get( new DomainId( "X" ) );
4266 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4269 cd = cdcc2.get( new DomainId( "Y" ) );
4270 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4273 cd = cdcc2.get( new DomainId( "Z" ) );
4274 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4277 cd = cdcc2.get( new DomainId( "NN" ) );
4278 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4281 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4284 cd = cdcc2.get( new DomainId( "MM" ) );
4285 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4288 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 0 ) {
4291 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 1 ) {
4294 cd = cdcc2.get( new DomainId( "OO" ) );
4295 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4298 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 0 ) {
4301 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 1 ) {
4304 cd = cdcc2.get( new DomainId( "QQ" ) );
4305 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4308 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "QQ" ) ) != 0 ) {
4311 cd = cdcc2.get( new DomainId( "singlet" ) );
4312 if ( cd.getKeyDomainCount() != 1 ) {
4315 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4318 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4321 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "singlet" ) ) != 0 ) {
4324 cd = cdcc2.get( new DomainId( "three" ) );
4325 if ( cd.getKeyDomainCount() != 3 ) {
4328 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4331 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4334 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 0 ) {
4337 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
4341 catch ( final Exception e ) {
4342 e.printStackTrace( System.out );
4348 private static boolean testDomainId() {
4350 final DomainId id1 = new DomainId( "a" );
4351 final DomainId id2 = new DomainId( "a" );
4352 final DomainId id3 = new DomainId( "A" );
4353 final DomainId id4 = new DomainId( "b" );
4354 if ( !id1.equals( id1 ) ) {
4357 if ( id1.getId().equals( "x" ) ) {
4360 if ( id1.getId().equals( null ) ) {
4363 if ( !id1.equals( id2 ) ) {
4366 if ( id1.equals( id3 ) ) {
4369 if ( id1.hashCode() != id1.hashCode() ) {
4372 if ( id1.hashCode() != id2.hashCode() ) {
4375 if ( id1.hashCode() == id3.hashCode() ) {
4378 if ( id1.compareTo( id1 ) != 0 ) {
4381 if ( id1.compareTo( id2 ) != 0 ) {
4384 if ( id1.compareTo( id3 ) != 0 ) {
4387 if ( id1.compareTo( id4 ) >= 0 ) {
4390 if ( id4.compareTo( id1 ) <= 0 ) {
4393 if ( !id4.getId().equals( "b" ) ) {
4396 final DomainId id5 = new DomainId( " C " );
4397 if ( !id5.getId().equals( "C" ) ) {
4400 if ( id5.equals( id1 ) ) {
4404 catch ( final Exception e ) {
4405 e.printStackTrace( System.out );
4411 private static boolean testDomainSorting() {
4413 final Domain A = new BasicDomain( "A", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4414 final Domain B = new BasicDomain( "B", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4415 final Domain C = new BasicDomain( "C", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.2, -12 );
4416 final Domain D = new BasicDomain( "D", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.3, -12 );
4417 final Domain E = new BasicDomain( "E", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.4, -12 );
4418 final Domain F = new BasicDomain( "F", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.5, -12 );
4419 final Domain G = new BasicDomain( "G", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.6, -12 );
4420 final Domain H1 = new BasicDomain( "H", ( short ) 100, ( short ) 200, ( short ) 1, ( short ) 5, 0.7, -12 );
4421 final Domain H2 = new BasicDomain( "H", ( short ) 300, ( short ) 400, ( short ) 2, ( short ) 5, 0.7, -12 );
4422 final Domain H3 = new BasicDomain( "H", ( short ) 500, ( short ) 600, ( short ) 3, ( short ) 5, 0.7, -12 );
4423 final Domain H4 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 4, ( short ) 5, 0.7, -12 );
4424 final Domain H5 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4425 final Domain H6 = new BasicDomain( "H",
4432 final Domain H7 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4433 final Domain H8 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 200, 0.7, -12 );
4434 final Protein protein = new BasicProtein( "00", "bat" );
4435 protein.addProteinDomain( H5 );
4436 protein.addProteinDomain( H2 );
4437 protein.addProteinDomain( H7 );
4438 protein.addProteinDomain( H6 );
4439 protein.addProteinDomain( A );
4440 protein.addProteinDomain( G );
4441 protein.addProteinDomain( H4 );
4442 protein.addProteinDomain( D );
4443 protein.addProteinDomain( H1 );
4444 protein.addProteinDomain( C );
4445 protein.addProteinDomain( E );
4446 protein.addProteinDomain( F );
4447 protein.addProteinDomain( B );
4448 protein.addProteinDomain( H3 );
4449 protein.addProteinDomain( H7 );
4450 protein.addProteinDomain( H7 );
4451 protein.addProteinDomain( H8 );
4452 final List<Domain> sorted = SurfacingUtil.sortDomainsWithAscendingConfidenceValues( protein );
4453 if ( sorted.size() != 17 ) {
4456 if ( !sorted.get( 0 ).getDomainId().getId().equals( "A" ) ) {
4459 if ( sorted.get( 0 ).getNumber() != 1 ) {
4462 if ( !sorted.get( 1 ).getDomainId().getId().equals( "B" ) ) {
4465 if ( sorted.get( 1 ).getNumber() != 1 ) {
4468 if ( !sorted.get( 2 ).getDomainId().getId().equals( "C" ) ) {
4471 if ( sorted.get( 2 ).getNumber() != 1 ) {
4474 if ( !sorted.get( 3 ).getDomainId().getId().equals( "D" ) ) {
4477 if ( sorted.get( 3 ).getNumber() != 1 ) {
4480 if ( !sorted.get( 4 ).getDomainId().getId().equals( "E" ) ) {
4483 if ( sorted.get( 4 ).getNumber() != 1 ) {
4486 if ( !sorted.get( 5 ).getDomainId().getId().equals( "F" ) ) {
4489 if ( sorted.get( 5 ).getNumber() != 1 ) {
4492 if ( !sorted.get( 6 ).getDomainId().getId().equals( "G" ) ) {
4495 if ( sorted.get( 6 ).getNumber() != 1 ) {
4498 if ( !sorted.get( 7 ).getDomainId().getId().equals( "H" ) ) {
4501 if ( sorted.get( 7 ).getNumber() != 5 ) {
4504 if ( !sorted.get( 8 ).getDomainId().getId().equals( "H" ) ) {
4507 if ( sorted.get( 8 ).getNumber() != 2 ) {
4510 if ( !sorted.get( 9 ).getDomainId().getId().equals( "H" ) ) {
4513 if ( sorted.get( 9 ).getNumber() != 6 ) {
4516 if ( !sorted.get( 10 ).getDomainId().getId().equals( "H" ) ) {
4519 if ( sorted.get( 10 ).getNumber() != 4 ) {
4522 if ( !sorted.get( 11 ).getDomainId().getId().equals( "H" ) ) {
4525 if ( sorted.get( 11 ).getNumber() != 1 ) {
4528 if ( sorted.get( 11 ).getTotalCount() != 5 ) {
4531 if ( !sorted.get( 12 ).getDomainId().getId().equals( "H" ) ) {
4534 if ( sorted.get( 12 ).getNumber() != 3 ) {
4537 if ( !sorted.get( 13 ).getDomainId().getId().equals( "H7" ) ) {
4540 if ( sorted.get( 13 ).getNumber() != 5 ) {
4543 if ( !sorted.get( 14 ).getDomainId().getId().equals( "H7" ) ) {
4546 if ( sorted.get( 14 ).getNumber() != 5 ) {
4549 if ( !sorted.get( 15 ).getDomainId().getId().equals( "H7" ) ) {
4552 if ( sorted.get( 15 ).getNumber() != 5 ) {
4555 // To check if sorting is stable [as claimed by Sun for
4556 // Collections.sort( List )]
4557 if ( !sorted.get( 16 ).getDomainId().getId().equals( "H7" ) ) {
4560 if ( sorted.get( 16 ).getNumber() != 5 ) {
4563 if ( sorted.get( 16 ).getTotalCount() != 200 ) {
4567 catch ( final Exception e ) {
4568 e.printStackTrace( System.out );
4574 private static boolean testEngulfingOverlapRemoval() {
4576 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4577 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
4578 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
4579 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4580 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4581 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4582 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
4583 final List<Boolean> covered = new ArrayList<Boolean>();
4584 covered.add( true ); // 0
4585 covered.add( false ); // 1
4586 covered.add( true ); // 2
4587 covered.add( false ); // 3
4588 covered.add( true ); // 4
4589 covered.add( true ); // 5
4590 covered.add( false ); // 6
4591 covered.add( true ); // 7
4592 covered.add( true ); // 8
4593 if ( SurfacingUtil.isEngulfed( d0, covered ) ) {
4596 if ( SurfacingUtil.isEngulfed( d1, covered ) ) {
4599 if ( SurfacingUtil.isEngulfed( d2, covered ) ) {
4602 if ( !SurfacingUtil.isEngulfed( d3, covered ) ) {
4605 if ( SurfacingUtil.isEngulfed( d4, covered ) ) {
4608 if ( SurfacingUtil.isEngulfed( d5, covered ) ) {
4611 if ( !SurfacingUtil.isEngulfed( d6, covered ) ) {
4614 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4615 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
4616 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
4617 final Protein abc = new BasicProtein( "abc", "nemve" );
4618 abc.addProteinDomain( a );
4619 abc.addProteinDomain( b );
4620 abc.addProteinDomain( c );
4621 final Protein abc_r1 = SurfacingUtil.removeOverlappingDomains( 3, false, abc );
4622 final Protein abc_r2 = SurfacingUtil.removeOverlappingDomains( 3, true, abc );
4623 if ( abc.getNumberOfProteinDomains() != 3 ) {
4626 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
4629 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
4632 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
4635 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "b" ) ) {
4638 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4639 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
4640 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
4641 final Protein def = new BasicProtein( "def", "nemve" );
4642 def.addProteinDomain( d );
4643 def.addProteinDomain( e );
4644 def.addProteinDomain( f );
4645 final Protein def_r1 = SurfacingUtil.removeOverlappingDomains( 5, false, def );
4646 final Protein def_r2 = SurfacingUtil.removeOverlappingDomains( 5, true, def );
4647 if ( def.getNumberOfProteinDomains() != 3 ) {
4650 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
4653 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
4656 if ( !def_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "d" ) ) {
4659 if ( !def_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "f" ) ) {
4662 if ( !def_r2.getProteinDomain( 2 ).getDomainId().getId().equals( "e" ) ) {
4666 catch ( final Exception e ) {
4667 e.printStackTrace( System.out );
4673 private static boolean testGenomeWideCombinableDomains() {
4675 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4676 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4677 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4678 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4679 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4680 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4681 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4682 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4683 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4684 final Protein eel_0 = new BasicProtein( "0", "eel" );
4685 final Protein eel_1 = new BasicProtein( "1", "eel" );
4686 final Protein eel_2 = new BasicProtein( "2", "eel" );
4687 final Protein eel_3 = new BasicProtein( "3", "eel" );
4688 final Protein eel_4 = new BasicProtein( "4", "eel" );
4689 final Protein eel_5 = new BasicProtein( "5", "eel" );
4690 final Protein eel_6 = new BasicProtein( "6", "eel" );
4691 eel_1.addProteinDomain( a );
4692 eel_2.addProteinDomain( a );
4693 eel_2.addProteinDomain( b );
4694 eel_3.addProteinDomain( a );
4695 eel_3.addProteinDomain( a );
4696 eel_3.addProteinDomain( b );
4697 eel_4.addProteinDomain( a );
4698 eel_4.addProteinDomain( b );
4699 eel_4.addProteinDomain( c );
4700 eel_4.addProteinDomain( d );
4701 eel_4.addProteinDomain( e );
4702 eel_5.addProteinDomain( e );
4703 eel_5.addProteinDomain( e );
4704 eel_5.addProteinDomain( f );
4705 eel_5.addProteinDomain( f );
4706 eel_5.addProteinDomain( f );
4707 eel_5.addProteinDomain( f );
4708 eel_6.addProteinDomain( g );
4709 eel_6.addProteinDomain( h );
4710 final List<Protein> protein_list_eel = new ArrayList<Protein>();
4711 protein_list_eel.add( eel_0 );
4712 protein_list_eel.add( eel_1 );
4713 protein_list_eel.add( eel_2 );
4714 protein_list_eel.add( eel_3 );
4715 protein_list_eel.add( eel_4 );
4716 protein_list_eel.add( eel_5 );
4717 protein_list_eel.add( eel_6 );
4718 final BasicGenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
4719 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
4720 final BasicGenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
4721 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
4722 if ( !eel_not_ignore.contains( new DomainId( "a" ) ) ) {
4725 if ( !eel_not_ignore.contains( new DomainId( "b" ) ) ) {
4728 if ( !eel_not_ignore.contains( new DomainId( "c" ) ) ) {
4731 if ( !eel_not_ignore.contains( new DomainId( "d" ) ) ) {
4734 if ( !eel_not_ignore.contains( new DomainId( "e" ) ) ) {
4737 if ( !eel_not_ignore.contains( new DomainId( "f" ) ) ) {
4740 if ( !eel_not_ignore.contains( new DomainId( "g" ) ) ) {
4743 if ( !eel_not_ignore.contains( new DomainId( "h" ) ) ) {
4746 if ( eel_not_ignore.contains( new DomainId( "x" ) ) ) {
4749 if ( !eel_ignore.contains( new DomainId( "a" ) ) ) {
4752 if ( !eel_ignore.contains( new DomainId( "b" ) ) ) {
4755 if ( !eel_ignore.contains( new DomainId( "c" ) ) ) {
4758 if ( !eel_ignore.contains( new DomainId( "d" ) ) ) {
4761 if ( !eel_ignore.contains( new DomainId( "e" ) ) ) {
4764 if ( !eel_ignore.contains( new DomainId( "f" ) ) ) {
4767 if ( !eel_ignore.contains( new DomainId( "g" ) ) ) {
4770 if ( !eel_ignore.contains( new DomainId( "h" ) ) ) {
4773 if ( eel_ignore.contains( new DomainId( "x" ) ) ) {
4776 if ( eel_not_ignore.getSize() != 8 ) {
4779 if ( eel_ignore.getSize() != 8 ) {
4782 if ( eel_not_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 5 ) {
4785 if ( eel_not_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4788 if ( eel_not_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4791 if ( eel_not_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4794 if ( eel_not_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 6 ) {
4797 if ( eel_not_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 2 ) {
4800 if ( eel_not_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4803 if ( eel_not_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4806 if ( eel_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 4 ) {
4809 if ( eel_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4812 if ( eel_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4815 if ( eel_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4818 if ( eel_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 5 ) {
4821 if ( eel_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 1 ) {
4824 if ( eel_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4827 if ( eel_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4830 if ( eel_not_ignore.getAllDomainIds().size() != 8 ) {
4833 if ( !eel_not_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4836 if ( !eel_not_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4839 if ( !eel_not_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4842 if ( !eel_not_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4845 if ( !eel_not_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4848 if ( !eel_not_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4851 if ( !eel_not_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4854 if ( !eel_not_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4857 if ( eel_not_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4860 if ( eel_ignore.getAllDomainIds().size() != 8 ) {
4863 if ( !eel_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4866 if ( !eel_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4869 if ( !eel_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4872 if ( !eel_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4875 if ( !eel_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4878 if ( !eel_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4881 if ( !eel_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4884 if ( !eel_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4887 if ( eel_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4890 final SortedSet<BinaryDomainCombination> bc0 = eel_not_ignore.toBinaryDomainCombinations();
4891 if ( bc0.size() != 15 ) {
4894 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4897 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4900 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4903 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4906 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4909 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4912 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4915 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4918 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4921 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4924 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
4927 if ( !bc0.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
4930 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
4933 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
4936 if ( !bc0.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
4939 if ( !bc0.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
4942 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
4945 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
4948 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "h" ) ) ) {
4951 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
4954 final SortedSet<BinaryDomainCombination> bc1 = eel_ignore.toBinaryDomainCombinations();
4955 if ( bc1.size() != 12 ) {
4958 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4961 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4964 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4967 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4970 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4973 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4976 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4979 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4982 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4985 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4988 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
4991 if ( !bc1.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
4994 if ( !bc1.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
4997 if ( !bc1.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
5000 if ( bc1.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
5003 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
5006 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
5009 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
5012 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
5015 if ( bc1.contains( new BasicBinaryDomainCombination( "b", "g" ) ) ) {
5019 catch ( final Exception e ) {
5020 e.printStackTrace( System.out );
5026 private static boolean testHmmPfamOutputParser( final File test_dir ) {
5028 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
5029 + ForesterUtil.getFileSeparator() + "hmmpfam_output" ), "human", "ls" );
5030 parser.setEValueMaximum( 0.2 );
5031 parser.setIgnoreDufs( true );
5032 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5033 List<?> domain_collections = null;
5034 domain_collections = parser.parse();
5035 if ( parser.getDomainsEncountered() != 4 ) {
5038 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
5041 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
5044 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
5047 if ( parser.getDomainsStored() != 3 ) {
5050 if ( domain_collections.size() != 1 ) {
5053 final Protein pdc = ( Protein ) domain_collections.get( 0 );
5054 if ( !pdc.getProteinId().equals( new ProteinId( "ENSP00000285681" ) ) ) {
5057 if ( !pdc.getSpecies().getSpeciesId().equals( "human" ) ) {
5060 if ( pdc.getNumberOfProteinDomains() != 3 ) {
5063 if ( !pdc.getAccession().equals( "acc_ENSP00000285681" ) ) {
5068 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
5071 final List<Domain> uba = pdc.getProteinDomains( new DomainId( "UBA" ) );
5072 final List<Domain> uim = pdc.getProteinDomains( new DomainId( "UIM" ) );
5073 final List<Domain> uch = pdc.getProteinDomains( new DomainId( "UCH" ) );
5074 if ( uba.size() != 1 ) {
5077 if ( uim.size() != 2 ) {
5080 if ( uch.size() != 0 ) {
5083 final BasicDomain uim_domain = ( BasicDomain ) uim.get( 1 );
5084 if ( !uim_domain.getDomainId().equals( new DomainId( "UIM" ) ) ) {
5087 if ( uim_domain.getTotalCount() != 2 ) {
5090 final BasicDomain uba_domain = ( BasicDomain ) uba.get( 0 );
5091 if ( !uba_domain.getDomainId().equals( new DomainId( "UBA" ) ) ) {
5094 if ( uba_domain.getNumber() != 1 ) {
5097 if ( uba_domain.getTotalCount() != 1 ) {
5100 if ( uba_domain.getFrom() != 16 ) {
5103 if ( uba_domain.getTo() != 57 ) {
5106 if ( !Test.isEqual( uba_domain.getPerSequenceEvalue(), 0.00084 ) ) {
5109 if ( !Test.isEqual( uba_domain.getPerSequenceScore(), 23.2 ) ) {
5112 final HmmPfamOutputParser parser2 = new HmmPfamOutputParser( new File( test_dir
5113 + ForesterUtil.getFileSeparator() + "hmmpfam_output_short" ), "human", "ls" );
5114 parser2.setEValueMaximum( 0.2 );
5115 parser2.setIgnoreDufs( true );
5116 parser2.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5117 List<Protein> domain_collections2 = null;
5118 domain_collections2 = parser2.parse();
5119 if ( parser2.getDomainsEncountered() != 4 ) {
5122 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
5125 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
5128 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
5131 if ( parser2.getDomainsStored() != 3 ) {
5134 if ( domain_collections2.size() != 1 ) {
5137 final Protein pdc2 = domain_collections2.get( 0 );
5138 if ( !pdc2.getProteinId().getId().equals( "ENSP00000285681" ) ) {
5141 if ( !pdc2.getSpecies().getSpeciesId().equals( "human" ) ) {
5144 if ( !pdc2.getName().equals( "" ) ) {
5147 if ( !pdc2.getAccession().equals( "223" ) ) {
5152 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
5155 if ( pdc2.getNumberOfProteinDomains() != 3 ) {
5158 final List<Domain> uba2 = pdc2.getProteinDomains( new DomainId( "UBA" ) );
5159 final List<Domain> uim2 = pdc2.getProteinDomains( new DomainId( "UIM" ) );
5160 final List<Domain> uch2 = pdc2.getProteinDomains( new DomainId( "UCH" ) );
5161 if ( uba2.size() != 1 ) {
5164 if ( uim2.size() != 2 ) {
5167 if ( uch2.size() != 0 ) {
5170 final BasicDomain uim_domain2 = ( BasicDomain ) uim2.get( 1 );
5171 if ( !uim_domain2.getDomainId().getId().equals( "UIM" ) ) {
5174 if ( uim_domain2.getTotalCount() != 2 ) {
5177 final BasicDomain uba_domain2 = ( BasicDomain ) uba2.get( 0 );
5178 if ( !uba_domain2.getDomainId().getId().equals( "UBA" ) ) {
5181 if ( uba_domain2.getNumber() != 1 ) {
5184 if ( uba_domain2.getTotalCount() != 1 ) {
5187 if ( uba_domain2.getFrom() != 16 ) {
5190 if ( uba_domain2.getTo() != 57 ) {
5193 if ( !Test.isEqual( uba_domain2.getPerSequenceEvalue(), 0.00084 ) ) {
5197 catch ( final Exception e ) {
5198 e.printStackTrace( System.out );
5204 private static boolean testHmmPfamOutputParserWithFilter( final File test_dir ) {
5206 HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator()
5207 + "hmmpfam_output3" ), "human", "ls" );
5208 parser.setEValueMaximum( 0.2 );
5209 parser.setIgnoreDufs( true );
5210 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5211 List<Protein> proteins = null;
5212 proteins = parser.parse();
5213 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5216 if ( proteins.size() != 4 ) {
5220 Set<DomainId> filter = new TreeSet<DomainId>();
5221 filter.add( new DomainId( "beauty" ) );
5222 filter.add( new DomainId( "strange" ) );
5223 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5227 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5228 parser.setEValueMaximum( 0.2 );
5229 parser.setIgnoreDufs( true );
5230 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5232 proteins = parser.parse();
5233 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5236 if ( proteins.size() != 4 ) {
5240 filter = new TreeSet<DomainId>();
5241 filter.add( new DomainId( "beauty" ) );
5242 filter.add( new DomainId( "strange" ) );
5243 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5247 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5248 parser.setEValueMaximum( 0.2 );
5249 parser.setIgnoreDufs( true );
5250 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5252 proteins = parser.parse();
5253 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
5256 if ( proteins.size() != 0 ) {
5260 filter = new TreeSet<DomainId>();
5261 filter.add( new DomainId( "UIM" ) );
5262 filter.add( new DomainId( "A" ) );
5263 filter.add( new DomainId( "C" ) );
5264 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5268 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5269 parser.setEValueMaximum( 0.2 );
5270 parser.setIgnoreDufs( true );
5271 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5273 proteins = parser.parse();
5274 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5277 if ( proteins.size() != 4 ) {
5281 filter = new TreeSet<DomainId>();
5282 filter.add( new DomainId( "UIM" ) );
5283 filter.add( new DomainId( "A" ) );
5284 filter.add( new DomainId( "C" ) );
5285 filter.add( new DomainId( "X" ) );
5286 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5290 HmmPfamOutputParser.FilterType.NEGATIVE_DOMAIN );
5291 parser.setEValueMaximum( 0.2 );
5292 parser.setIgnoreDufs( true );
5293 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5295 proteins = parser.parse();
5296 if ( parser.getDomainsIgnoredDueToNegativeDomainFilter() != 7 ) {
5299 if ( proteins.size() != 3 ) {
5303 filter = new TreeSet<DomainId>();
5304 filter.add( new DomainId( "UIM" ) );
5305 filter.add( new DomainId( "A" ) );
5306 filter.add( new DomainId( "C" ) );
5307 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5311 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5312 parser.setEValueMaximum( 0.2 );
5313 parser.setIgnoreDufs( true );
5314 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5316 proteins = parser.parse();
5317 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
5320 if ( proteins.size() != 0 ) {
5324 filter = new TreeSet<DomainId>();
5325 filter.add( new DomainId( "UIM" ) );
5326 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5330 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5331 parser.setEValueMaximum( 0.2 );
5332 parser.setIgnoreDufs( true );
5333 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5335 proteins = parser.parse();
5336 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
5339 if ( parser.getProteinsStored() != 3 ) {
5342 if ( proteins.size() != 3 ) {
5346 filter = new TreeSet<DomainId>();
5347 filter.add( new DomainId( "UIM" ) );
5348 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5352 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5353 parser.setEValueMaximum( 0.2 );
5354 parser.setIgnoreDufs( true );
5355 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5357 proteins = parser.parse();
5358 if ( parser.getProteinsIgnoredDueToFilter() != 3 ) {
5361 if ( parser.getProteinsStored() != 1 ) {
5364 if ( proteins.size() != 1 ) {
5368 filter = new TreeSet<DomainId>();
5369 filter.add( new DomainId( "A" ) );
5370 filter.add( new DomainId( "C" ) );
5371 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5375 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5376 parser.setEValueMaximum( 0.2 );
5377 parser.setIgnoreDufs( true );
5378 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5380 proteins = parser.parse();
5381 if ( parser.getDomainsEncountered() != 11 ) {
5384 if ( parser.getProteinsEncountered() != 4 ) {
5387 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
5390 if ( parser.getProteinsStored() != 3 ) {
5393 if ( proteins.size() != 3 ) {
5397 catch ( final Exception e ) {
5398 e.printStackTrace( System.out );
5404 private static boolean testOverlapRemoval() {
5406 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
5407 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5408 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
5409 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5410 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
5411 final List<Boolean> covered = new ArrayList<Boolean>();
5412 covered.add( true ); // 0
5413 covered.add( false ); // 1
5414 covered.add( true ); // 2
5415 covered.add( false ); // 3
5416 covered.add( true ); // 4
5417 covered.add( true ); // 5
5418 covered.add( false ); // 6
5419 covered.add( true ); // 7
5420 covered.add( true ); // 8
5421 if ( SurfacingUtil.calculateOverlap( d0, covered ) != 3 ) {
5424 if ( SurfacingUtil.calculateOverlap( d1, covered ) != 2 ) {
5427 if ( SurfacingUtil.calculateOverlap( d2, covered ) != 6 ) {
5430 if ( SurfacingUtil.calculateOverlap( d3, covered ) != 0 ) {
5433 if ( SurfacingUtil.calculateOverlap( d4, covered ) != 2 ) {
5436 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.01, 1 );
5437 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5438 final Protein ab = new BasicProtein( "ab", "varanus" );
5439 ab.addProteinDomain( a );
5440 ab.addProteinDomain( b );
5441 final Protein ab_s0 = SurfacingUtil.removeOverlappingDomains( 3, false, ab );
5442 if ( ab.getNumberOfProteinDomains() != 2 ) {
5445 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
5448 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
5451 final Protein ab_s1 = SurfacingUtil.removeOverlappingDomains( 4, false, ab );
5452 if ( ab.getNumberOfProteinDomains() != 2 ) {
5455 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
5458 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
5459 final Domain d = new BasicDomain( "d",
5466 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
5467 final Protein cde = new BasicProtein( "cde", "varanus" );
5468 cde.addProteinDomain( c );
5469 cde.addProteinDomain( d );
5470 cde.addProteinDomain( e );
5471 final Protein cde_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, cde );
5472 if ( cde.getNumberOfProteinDomains() != 3 ) {
5475 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
5478 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5479 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5480 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5481 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
5482 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
5483 final Protein fghi = new BasicProtein( "fghi", "varanus" );
5484 fghi.addProteinDomain( f );
5485 fghi.addProteinDomain( g );
5486 fghi.addProteinDomain( h );
5487 fghi.addProteinDomain( i );
5488 fghi.addProteinDomain( i );
5489 fghi.addProteinDomain( i );
5490 fghi.addProteinDomain( i2 );
5491 final Protein fghi_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, fghi );
5492 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5495 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
5498 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "h" ) ) {
5501 final Protein fghi_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, fghi );
5502 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5505 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
5508 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5509 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5510 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5511 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
5512 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
5513 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
5514 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5515 final Protein jklm = new BasicProtein( "jklm", "varanus" );
5516 jklm.addProteinDomain( j );
5517 jklm.addProteinDomain( k );
5518 jklm.addProteinDomain( l );
5519 jklm.addProteinDomain( m );
5520 jklm.addProteinDomain( m0 );
5521 jklm.addProteinDomain( m1 );
5522 jklm.addProteinDomain( m2 );
5523 final Protein jklm_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, jklm );
5524 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5527 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
5530 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "l" ) ) {
5533 final Protein jklm_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, jklm );
5534 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5537 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
5540 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5541 final Protein od = new BasicProtein( "od", "varanus" );
5542 od.addProteinDomain( only );
5543 final Protein od_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, od );
5544 if ( od.getNumberOfProteinDomains() != 1 ) {
5547 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
5551 catch ( final Exception e ) {
5552 e.printStackTrace( System.out );
5558 private static boolean testParsimony() {
5560 final BinaryStates X = BinaryStates.PRESENT;
5561 final BinaryStates O = BinaryStates.ABSENT;
5562 final GainLossStates G = GainLossStates.GAIN;
5563 final GainLossStates L = GainLossStates.LOSS;
5564 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5565 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5566 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5567 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5568 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5569 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5570 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5571 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5572 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5573 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5574 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5575 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5576 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5577 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5578 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5579 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5580 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5581 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5582 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5583 // 1 a-a a-b a-c e-f-g-h l-m
5584 // 2 a-b a-c e-f-g-i n-o
5585 // 3 a-b a-d e-f-g-j p-q
5587 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5588 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5589 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5591 // 1 a b c e f g h l m
5592 // 2 a b c e f g i n o
5593 // 3 a b d e f g j p q
5595 final Protein aa1 = new BasicProtein( "aa1", "one" );
5596 aa1.addProteinDomain( a );
5597 aa1.addProteinDomain( a );
5598 final Protein ab1 = new BasicProtein( "ab1", "one" );
5599 ab1.addProteinDomain( a );
5600 ab1.addProteinDomain( b );
5601 final Protein ac1 = new BasicProtein( "ac1", "one" );
5602 ac1.addProteinDomain( a );
5603 ac1.addProteinDomain( c );
5604 final Protein efgh1 = new BasicProtein( "efgh1", "one" );
5605 efgh1.addProteinDomain( e );
5606 efgh1.addProteinDomain( f );
5607 efgh1.addProteinDomain( g );
5608 efgh1.addProteinDomain( h );
5609 final Protein lm1 = new BasicProtein( "lm1", "one" );
5610 lm1.addProteinDomain( l );
5611 lm1.addProteinDomain( m );
5612 final Protein ab2 = new BasicProtein( "ab2", "two" );
5613 ab2.addProteinDomain( a );
5614 ab2.addProteinDomain( b );
5615 final Protein ac2 = new BasicProtein( "ac2", "two" );
5616 ac2.addProteinDomain( a );
5617 ac2.addProteinDomain( c );
5618 final Protein efgi2 = new BasicProtein( "efgi2", "two" );
5619 efgi2.addProteinDomain( e );
5620 efgi2.addProteinDomain( f );
5621 efgi2.addProteinDomain( g );
5622 efgi2.addProteinDomain( i );
5623 final Protein no2 = new BasicProtein( "no2", "two" );
5624 no2.addProteinDomain( n );
5625 no2.addProteinDomain( o );
5626 final Protein ab3 = new BasicProtein( "ab3", "three" );
5627 ab3.addProteinDomain( a );
5628 ab3.addProteinDomain( b );
5629 final Protein ad3 = new BasicProtein( "ad3", "three" );
5630 ad3.addProteinDomain( a );
5631 ad3.addProteinDomain( d );
5632 final Protein efgj3 = new BasicProtein( "efgj3", "three" );
5633 efgj3.addProteinDomain( e );
5634 efgj3.addProteinDomain( f );
5635 efgj3.addProteinDomain( g );
5636 efgj3.addProteinDomain( j );
5637 final Protein pq3 = new BasicProtein( "pq3", "three" );
5638 pq3.addProteinDomain( p );
5639 pq3.addProteinDomain( q );
5640 final Protein ab4 = new BasicProtein( "ab4", "four" );
5641 ab4.addProteinDomain( a );
5642 ab4.addProteinDomain( b );
5643 final Protein ad4 = new BasicProtein( "ad4", "four" );
5644 ad4.addProteinDomain( a );
5645 ad4.addProteinDomain( d );
5646 final Protein pr4 = new BasicProtein( "pr4", "four" );
5647 pr4.addProteinDomain( p );
5648 pr4.addProteinDomain( r );
5649 final List<Protein> one_list = new ArrayList<Protein>();
5650 one_list.add( aa1 );
5651 one_list.add( ab1 );
5652 one_list.add( ac1 );
5653 one_list.add( efgh1 );
5654 one_list.add( lm1 );
5655 final List<Protein> two_list = new ArrayList<Protein>();
5656 two_list.add( ab2 );
5657 two_list.add( ac2 );
5658 two_list.add( efgi2 );
5659 two_list.add( no2 );
5660 final List<Protein> three_list = new ArrayList<Protein>();
5661 three_list.add( ab3 );
5662 three_list.add( ad3 );
5663 three_list.add( efgj3 );
5664 three_list.add( pq3 );
5665 final List<Protein> four_list = new ArrayList<Protein>();
5666 four_list.add( ab4 );
5667 four_list.add( ad4 );
5668 four_list.add( pr4 );
5669 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5670 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5671 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5672 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5673 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5674 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5675 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5676 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5677 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5678 gwcd_list.add( one );
5679 gwcd_list.add( two );
5680 gwcd_list.add( three );
5681 gwcd_list.add( four );
5682 final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
5683 .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
5684 final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
5685 .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
5686 // 1 a b c e f g h l m
5687 // 2 a b c e f g i n o
5688 // 3 a b d e f g j p q
5690 if ( matrix_d.getState( 0, 0 ) != X ) {
5693 if ( matrix_d.getState( 0, 1 ) != X ) {
5696 if ( matrix_d.getState( 0, 2 ) != X ) {
5699 if ( matrix_d.getState( 0, 3 ) != O ) {
5702 if ( matrix_d.getState( 0, 4 ) != X ) {
5705 if ( matrix_d.getState( 0, 5 ) != X ) {
5708 if ( matrix_d.getState( 0, 6 ) != X ) {
5711 if ( matrix_d.getState( 0, 7 ) != X ) {
5714 if ( matrix_d.getState( 0, 8 ) != O ) {
5717 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5718 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5719 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5721 if ( matrix_bc.getState( 0, 0 ) != X ) {
5724 if ( matrix_bc.getState( 0, 1 ) != X ) {
5727 if ( matrix_bc.getState( 0, 2 ) != X ) {
5730 if ( matrix_bc.getState( 0, 3 ) != O ) {
5733 if ( matrix_bc.getState( 0, 4 ) != X ) {
5736 if ( matrix_bc.getState( 1, 0 ) != O ) {
5739 if ( matrix_bc.getState( 1, 1 ) != X ) {
5742 if ( matrix_bc.getState( 1, 2 ) != X ) {
5745 if ( matrix_bc.getState( 1, 3 ) != O ) {
5748 if ( matrix_bc.getState( 1, 4 ) != X ) {
5751 if ( matrix_bc.getState( 2, 0 ) != O ) {
5754 if ( matrix_bc.getState( 2, 1 ) != X ) {
5757 if ( matrix_bc.getState( 2, 2 ) != O ) {
5760 if ( matrix_bc.getState( 2, 3 ) != X ) {
5763 if ( matrix_bc.getState( 2, 4 ) != X ) {
5766 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
5767 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
5768 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
5769 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list );
5770 dp0.executeDolloParsimonyOnDomainPresence();
5771 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
5772 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
5773 dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
5774 final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
5775 final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
5776 if ( is_matrix_d.getState( "root", "A" ) != X ) {
5779 if ( is_matrix_d.getState( "root", "B" ) != X ) {
5782 if ( is_matrix_d.getState( "root", "C" ) != O ) {
5785 if ( is_matrix_d.getState( "root", "D" ) != O ) {
5788 if ( is_matrix_d.getState( "root", "E" ) != X ) {
5791 if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
5794 if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
5797 if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
5800 if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
5803 if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
5806 if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
5809 if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
5812 if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
5815 if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
5818 if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
5821 if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
5824 if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
5827 if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
5830 if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
5834 catch ( final Exception e ) {
5835 e.printStackTrace( System.out );
5841 private static boolean testParsimonyOnSecondaryFeatures() {
5843 final BinaryStates X = BinaryStates.PRESENT;
5844 final BinaryStates O = BinaryStates.ABSENT;
5845 final GainLossStates G = GainLossStates.GAIN;
5846 final GainLossStates L = GainLossStates.LOSS;
5847 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5848 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5849 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5850 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5851 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5852 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5853 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5854 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5855 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5856 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5857 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5858 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5859 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5860 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5861 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5862 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5863 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5864 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5865 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5866 // 1 a-a a-b a-c e-f-g-h l-m
5867 // 2 a-b a-c e-f-g-i n-o
5868 // 3 a-b a-d e-f-g-j p-q
5870 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5871 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5872 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5874 // 1 a b c e f g h l m
5875 // 2 a b c e f g i n o
5876 // 3 a b d e f g j p q
5878 final Protein aa1 = new BasicProtein( "aa1", "one" );
5879 aa1.addProteinDomain( a );
5880 aa1.addProteinDomain( a );
5881 final Protein ab1 = new BasicProtein( "ab1", "one" );
5882 ab1.addProteinDomain( a );
5883 ab1.addProteinDomain( b );
5884 final Protein ac1 = new BasicProtein( "ac1", "one" );
5885 ac1.addProteinDomain( a );
5886 ac1.addProteinDomain( c );
5887 final Protein efgh1 = new BasicProtein( "efgh1", "one" );
5888 efgh1.addProteinDomain( e );
5889 efgh1.addProteinDomain( f );
5890 efgh1.addProteinDomain( g );
5891 efgh1.addProteinDomain( h );
5892 final Protein lm1 = new BasicProtein( "lm1", "one" );
5893 lm1.addProteinDomain( l );
5894 lm1.addProteinDomain( m );
5895 final Protein ab2 = new BasicProtein( "ab2", "two" );
5896 ab2.addProteinDomain( a );
5897 ab2.addProteinDomain( b );
5898 final Protein ac2 = new BasicProtein( "ac2", "two" );
5899 ac2.addProteinDomain( a );
5900 ac2.addProteinDomain( c );
5901 final Protein efgi2 = new BasicProtein( "efgi2", "two" );
5902 efgi2.addProteinDomain( e );
5903 efgi2.addProteinDomain( f );
5904 efgi2.addProteinDomain( g );
5905 efgi2.addProteinDomain( i );
5906 final Protein no2 = new BasicProtein( "no2", "two" );
5907 no2.addProteinDomain( n );
5908 no2.addProteinDomain( o );
5909 final Protein ab3 = new BasicProtein( "ab3", "three" );
5910 ab3.addProteinDomain( a );
5911 ab3.addProteinDomain( b );
5912 final Protein ad3 = new BasicProtein( "ad3", "three" );
5913 ad3.addProteinDomain( a );
5914 ad3.addProteinDomain( d );
5915 final Protein efgj3 = new BasicProtein( "efgj3", "three" );
5916 efgj3.addProteinDomain( e );
5917 efgj3.addProteinDomain( f );
5918 efgj3.addProteinDomain( g );
5919 efgj3.addProteinDomain( j );
5920 final Protein pq3 = new BasicProtein( "pq3", "three" );
5921 pq3.addProteinDomain( p );
5922 pq3.addProteinDomain( q );
5923 final Protein ab4 = new BasicProtein( "ab4", "four" );
5924 ab4.addProteinDomain( a );
5925 ab4.addProteinDomain( b );
5926 final Protein ad4 = new BasicProtein( "ad4", "four" );
5927 ad4.addProteinDomain( a );
5928 ad4.addProteinDomain( d );
5929 final Protein pr4 = new BasicProtein( "pr4", "four" );
5930 pr4.addProteinDomain( p );
5931 pr4.addProteinDomain( r );
5932 final List<Protein> one_list = new ArrayList<Protein>();
5933 one_list.add( aa1 );
5934 one_list.add( ab1 );
5935 one_list.add( ac1 );
5936 one_list.add( efgh1 );
5937 one_list.add( lm1 );
5938 final List<Protein> two_list = new ArrayList<Protein>();
5939 two_list.add( ab2 );
5940 two_list.add( ac2 );
5941 two_list.add( efgi2 );
5942 two_list.add( no2 );
5943 final List<Protein> three_list = new ArrayList<Protein>();
5944 three_list.add( ab3 );
5945 three_list.add( ad3 );
5946 three_list.add( efgj3 );
5947 three_list.add( pq3 );
5948 final List<Protein> four_list = new ArrayList<Protein>();
5949 four_list.add( ab4 );
5950 four_list.add( ad4 );
5951 four_list.add( pr4 );
5952 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5953 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5954 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5955 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5956 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5957 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5958 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5959 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5960 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5961 gwcd_list.add( one );
5962 gwcd_list.add( two );
5963 gwcd_list.add( three );
5964 gwcd_list.add( four );
5965 final Map<DomainId, Set<String>> map_same = new HashMap<DomainId, Set<String>>();
5966 final HashSet<String> a_s = new HashSet<String>();
5968 final HashSet<String> b_s = new HashSet<String>();
5970 final HashSet<String> c_s = new HashSet<String>();
5972 final HashSet<String> d_s = new HashSet<String>();
5974 final HashSet<String> e_s = new HashSet<String>();
5976 final HashSet<String> f_s = new HashSet<String>();
5978 final HashSet<String> g_s = new HashSet<String>();
5980 final HashSet<String> h_s = new HashSet<String>();
5982 final HashSet<String> i_s = new HashSet<String>();
5984 final HashSet<String> j_s = new HashSet<String>();
5986 final HashSet<String> l_s = new HashSet<String>();
5988 final HashSet<String> m_s = new HashSet<String>();
5990 final HashSet<String> n_s = new HashSet<String>();
5992 final HashSet<String> o_s = new HashSet<String>();
5994 final HashSet<String> p_s = new HashSet<String>();
5996 final HashSet<String> q_s = new HashSet<String>();
5998 final HashSet<String> r_s = new HashSet<String>();
6000 map_same.put( a.getDomainId(), a_s );
6001 map_same.put( b.getDomainId(), b_s );
6002 map_same.put( c.getDomainId(), c_s );
6003 map_same.put( d.getDomainId(), d_s );
6004 map_same.put( e.getDomainId(), e_s );
6005 map_same.put( f.getDomainId(), f_s );
6006 map_same.put( g.getDomainId(), g_s );
6007 map_same.put( h.getDomainId(), h_s );
6008 map_same.put( i.getDomainId(), i_s );
6009 map_same.put( j.getDomainId(), j_s );
6010 map_same.put( l.getDomainId(), l_s );
6011 map_same.put( m.getDomainId(), m_s );
6012 map_same.put( n.getDomainId(), n_s );
6013 map_same.put( o.getDomainId(), o_s );
6014 map_same.put( p.getDomainId(), p_s );
6015 map_same.put( q.getDomainId(), q_s );
6016 map_same.put( r.getDomainId(), r_s );
6017 final CharacterStateMatrix<BinaryStates> matrix_s = DomainParsimonyCalculator
6018 .createMatrixOfSecondaryFeaturePresenceOrAbsence( gwcd_list, map_same, null );
6019 // 1 a b c e f g h l m
6020 // 2 a b c e f g i n o
6021 // 3 a b d e f g j p q
6023 if ( matrix_s.getState( 0, 0 ) != X ) {
6026 if ( matrix_s.getState( 0, 1 ) != X ) {
6029 if ( matrix_s.getState( 0, 2 ) != X ) {
6032 if ( matrix_s.getState( 0, 3 ) != O ) {
6035 if ( matrix_s.getState( 0, 4 ) != X ) {
6038 if ( matrix_s.getState( 0, 5 ) != X ) {
6041 if ( matrix_s.getState( 0, 6 ) != X ) {
6044 if ( matrix_s.getState( 0, 7 ) != X ) {
6047 if ( matrix_s.getState( 0, 8 ) != O ) {
6050 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
6051 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
6052 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
6053 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list, map_same );
6054 dp0.executeDolloParsimonyOnSecondaryFeatures( null );
6055 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
6056 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
6057 if ( is_matrix_d.getState( "root", "AAA" ) != X ) {
6060 if ( is_matrix_d.getState( "root", "BBB" ) != X ) {
6063 if ( is_matrix_d.getState( "root", "CCC" ) != O ) {
6066 if ( is_matrix_d.getState( "root", "DDD" ) != O ) {
6069 if ( is_matrix_d.getState( "root", "EEE" ) != X ) {
6072 if ( gl_matrix_d.getState( "3-4", "PPP" ) != G ) {
6076 catch ( final Exception e ) {
6077 e.printStackTrace( System.out );
6083 private static boolean testPaupLogParser( final File test_dir ) {
6085 final PaupLogParser parser = new PaupLogParser();
6086 parser.setSource( new File( test_dir + ForesterUtil.getFileSeparator() + "paup_log_test_1" ) );
6087 final CharacterStateMatrix<BinaryStates> matrix = parser.parse();
6088 if ( matrix.getNumberOfIdentifiers() != 8 ) {
6091 if ( !matrix.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6094 if ( !matrix.getIdentifier( 1 ).equals( "NEMVE" ) ) {
6097 if ( !matrix.getIdentifier( 2 ).equals( "MONBE" ) ) {
6100 if ( !matrix.getIdentifier( 3 ).equals( "DICDI" ) ) {
6103 if ( !matrix.getIdentifier( 4 ).equals( "ARATH" ) ) {
6106 if ( !matrix.getIdentifier( 5 ).equals( "6" ) ) {
6109 if ( !matrix.getIdentifier( 6 ).equals( "7" ) ) {
6112 if ( !matrix.getIdentifier( 7 ).equals( "8" ) ) {
6115 if ( matrix.getNumberOfCharacters() != ( 66 + 66 + 28 ) ) {
6118 if ( matrix.getState( 0, 4 ) != BinaryStates.ABSENT ) {
6121 if ( matrix.getState( 0, 5 ) != BinaryStates.PRESENT ) {
6124 if ( matrix.getState( 1, 5 ) != BinaryStates.PRESENT ) {
6127 if ( matrix.getState( 7, 154 ) != BinaryStates.ABSENT ) {
6130 if ( matrix.getState( 7, 155 ) != BinaryStates.PRESENT ) {
6133 if ( matrix.getState( 7, 156 ) != BinaryStates.PRESENT ) {
6136 if ( matrix.getState( 7, 157 ) != BinaryStates.ABSENT ) {
6139 if ( matrix.getState( 7, 158 ) != BinaryStates.PRESENT ) {
6142 if ( matrix.getState( 7, 159 ) != BinaryStates.ABSENT ) {
6146 catch ( final Exception e ) {
6147 e.printStackTrace( System.out );
6153 private static boolean testProteinId() {
6155 final ProteinId id1 = new ProteinId( "a" );
6156 final ProteinId id2 = new ProteinId( "a" );
6157 final ProteinId id3 = new ProteinId( "A" );
6158 final ProteinId id4 = new ProteinId( "b" );
6159 if ( !id1.equals( id1 ) ) {
6162 if ( id1.getId().equals( "x" ) ) {
6165 if ( id1.getId().equals( null ) ) {
6168 if ( !id1.equals( id2 ) ) {
6171 if ( id1.equals( id3 ) ) {
6174 if ( id1.hashCode() != id1.hashCode() ) {
6177 if ( id1.hashCode() != id2.hashCode() ) {
6180 if ( id1.hashCode() == id3.hashCode() ) {
6183 if ( id1.compareTo( id1 ) != 0 ) {
6186 if ( id1.compareTo( id2 ) != 0 ) {
6189 if ( id1.compareTo( id3 ) != 0 ) {
6192 if ( id1.compareTo( id4 ) >= 0 ) {
6195 if ( id4.compareTo( id1 ) <= 0 ) {
6198 if ( !id4.getId().equals( "b" ) ) {
6201 final ProteinId id5 = new ProteinId( " C " );
6202 if ( !id5.getId().equals( "C" ) ) {
6205 if ( id5.equals( id1 ) ) {
6209 catch ( final Exception e ) {
6210 e.printStackTrace( System.out );
6216 private static boolean testSpecies() {
6218 final Species s1 = new BasicSpecies( "a" );
6219 final Species s2 = new BasicSpecies( "a" );
6220 final Species s3 = new BasicSpecies( "A" );
6221 final Species s4 = new BasicSpecies( "b" );
6222 if ( !s1.equals( s1 ) ) {
6225 if ( s1.getSpeciesId().equals( "x" ) ) {
6228 if ( s1.getSpeciesId().equals( null ) ) {
6231 if ( !s1.equals( s2 ) ) {
6234 if ( s1.equals( s3 ) ) {
6237 if ( s1.hashCode() != s1.hashCode() ) {
6240 if ( s1.hashCode() != s2.hashCode() ) {
6243 if ( s1.hashCode() == s3.hashCode() ) {
6246 if ( s1.compareTo( s1 ) != 0 ) {
6249 if ( s1.compareTo( s2 ) != 0 ) {
6252 if ( s1.compareTo( s3 ) != 0 ) {
6255 if ( s1.compareTo( s4 ) >= 0 ) {
6258 if ( s4.compareTo( s1 ) <= 0 ) {
6261 if ( !s4.getSpeciesId().equals( "b" ) ) {
6264 final Species s5 = new BasicSpecies( " C " );
6265 if ( !s5.getSpeciesId().equals( "C" ) ) {
6268 if ( s5.equals( s1 ) ) {
6272 catch ( final Exception e ) {
6273 e.printStackTrace( System.out );