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" ) ) {
1599 if ( !s0.equals( s0 ) ) {
1602 if ( s0.equals( s1 ) ) {
1605 if ( s1.equals( s0 ) ) {
1608 if ( !s1.equals( s2 ) ) {
1611 if ( !s2.equals( s1 ) ) {
1614 if ( s2.equals( s3 ) ) {
1617 if ( s2.equals( s3 ) ) {
1620 if ( s2.equals( s4 ) ) {
1623 final SortedSet<BasicBinaryDomainCombination> sorted = new TreeSet<BasicBinaryDomainCombination>();
1636 if ( sorted.size() != 6 ) {
1639 final DirectedBinaryDomainCombination aa = new DirectedBinaryDomainCombination( "a", "a" );
1640 final DirectedBinaryDomainCombination ba = new DirectedBinaryDomainCombination( "b", "a" );
1641 final DirectedBinaryDomainCombination ab = new DirectedBinaryDomainCombination( "a", "b" );
1642 final DirectedBinaryDomainCombination bb = new DirectedBinaryDomainCombination( "b", "b" );
1643 if ( !aa.equals( aa ) ) {
1646 if ( aa.equals( bb ) ) {
1649 if ( ab.equals( ba ) ) {
1652 if ( ba.equals( ab ) ) {
1655 if ( !ab.equals( ab ) ) {
1658 if ( ab.equals( aa ) ) {
1661 if ( ab.equals( bb ) ) {
1665 catch ( final Exception e ) {
1666 e.printStackTrace( System.out );
1672 private static boolean testBinaryStateMatrixToGainLossMatrix( final File test_dir ) {
1673 final BinaryStates I = BinaryStates.PRESENT;
1674 final BinaryStates O = BinaryStates.ABSENT;
1676 final CharacterStateMatrix<BinaryStates> binary_states_matrix_0 = new BasicCharacterStateMatrix<BinaryStates>( 7,
1678 binary_states_matrix_0.setIdentifier( 0, "A" );
1679 binary_states_matrix_0.setIdentifier( 1, "B" );
1680 binary_states_matrix_0.setIdentifier( 2, "C" );
1681 binary_states_matrix_0.setIdentifier( 3, "D" );
1682 binary_states_matrix_0.setIdentifier( 4, "1" );
1683 binary_states_matrix_0.setIdentifier( 5, "2" );
1684 binary_states_matrix_0.setIdentifier( 6, "3" );
1685 binary_states_matrix_0.setState( 0, 0, O );
1686 binary_states_matrix_0.setState( 1, 0, O );
1687 binary_states_matrix_0.setState( 2, 0, O );
1688 binary_states_matrix_0.setState( 3, 0, O );
1689 binary_states_matrix_0.setState( 4, 0, O );
1690 binary_states_matrix_0.setState( 5, 0, O );
1691 binary_states_matrix_0.setState( 6, 0, O );
1692 binary_states_matrix_0.setState( 0, 1, I );
1693 binary_states_matrix_0.setState( 1, 1, O );
1694 binary_states_matrix_0.setState( 2, 1, O );
1695 binary_states_matrix_0.setState( 3, 1, O );
1696 binary_states_matrix_0.setState( 4, 1, O );
1697 binary_states_matrix_0.setState( 5, 1, O );
1698 binary_states_matrix_0.setState( 6, 1, O );
1699 binary_states_matrix_0.setState( 0, 2, O );
1700 binary_states_matrix_0.setState( 1, 2, O );
1701 binary_states_matrix_0.setState( 2, 2, O );
1702 binary_states_matrix_0.setState( 3, 2, O );
1703 binary_states_matrix_0.setState( 4, 2, I );
1704 binary_states_matrix_0.setState( 5, 2, O );
1705 binary_states_matrix_0.setState( 6, 2, O );
1706 binary_states_matrix_0.setState( 0, 3, I );
1707 binary_states_matrix_0.setState( 1, 3, O );
1708 binary_states_matrix_0.setState( 2, 3, O );
1709 binary_states_matrix_0.setState( 3, 3, O );
1710 binary_states_matrix_0.setState( 4, 3, I );
1711 binary_states_matrix_0.setState( 5, 3, O );
1712 binary_states_matrix_0.setState( 6, 3, I );
1713 binary_states_matrix_0.setState( 0, 4, I );
1714 binary_states_matrix_0.setState( 1, 4, O );
1715 binary_states_matrix_0.setState( 2, 4, I );
1716 binary_states_matrix_0.setState( 3, 4, O );
1717 binary_states_matrix_0.setState( 4, 4, I );
1718 binary_states_matrix_0.setState( 5, 4, O );
1719 binary_states_matrix_0.setState( 6, 4, I );
1720 binary_states_matrix_0.setState( 0, 5, I );
1721 binary_states_matrix_0.setState( 1, 5, I );
1722 binary_states_matrix_0.setState( 2, 5, I );
1723 binary_states_matrix_0.setState( 3, 5, I );
1724 binary_states_matrix_0.setState( 4, 5, I );
1725 binary_states_matrix_0.setState( 5, 5, I );
1726 binary_states_matrix_0.setState( 6, 5, I );
1727 final String[] character_labels_0 = new String[ 6 ];
1728 character_labels_0[ 0 ] = "first";
1729 character_labels_0[ 1 ] = "second";
1730 character_labels_0[ 2 ] = "third";
1731 character_labels_0[ 3 ] = "forth";
1732 character_labels_0[ 4 ] = "fifth";
1733 character_labels_0[ 5 ] = "sixth";
1734 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1735 final Phylogeny phylogeny_0 = factory.create( "(((A,B)1,C)2,D)3", new NHXParser() )[ 0 ];
1736 final DomainParsimonyCalculator dom_pars = DomainParsimonyCalculator.createInstance( phylogeny_0 );
1737 dom_pars.executeOnGivenBinaryStatesMatrix( binary_states_matrix_0, character_labels_0 );
1738 final CharacterStateMatrix<GainLossStates> gl_matrix_0 = dom_pars.getGainLossMatrix();
1739 // final StringWriter sw = new StringWriter();
1740 // gl_matrix_0.toWriter( sw );
1741 // System.out.println( sw.toString() );
1742 if ( dom_pars.getCost() != 13 ) {
1745 if ( dom_pars.getTotalGains() != 5 ) {
1748 if ( dom_pars.getTotalLosses() != 8 ) {
1751 if ( dom_pars.getTotalUnchanged() != 29 ) {
1754 if ( gl_matrix_0.getState( "A", 1 ) != GainLossStates.GAIN ) {
1757 if ( gl_matrix_0.getState( "A", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1760 if ( gl_matrix_0.getState( "B", 4 ) != GainLossStates.LOSS ) {
1763 if ( gl_matrix_0.getState( "C", 4 ) != GainLossStates.GAIN ) {
1766 if ( gl_matrix_0.getState( "D", 4 ) != GainLossStates.LOSS ) {
1769 if ( gl_matrix_0.getState( "1", 4 ) != GainLossStates.GAIN ) {
1772 if ( gl_matrix_0.getState( "2", 4 ) != GainLossStates.LOSS ) {
1775 if ( gl_matrix_0.getState( "3", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1779 catch ( final Exception e ) {
1780 e.printStackTrace( System.out );
1786 private static boolean testCombinableDomains() {
1788 final Domain key0 = new BasicDomain( "key0", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1789 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1790 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1791 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1792 final CombinableDomains cd0 = new BasicCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
1793 cd0.addCombinableDomain( a.getDomainId() );
1794 cd0.addCombinableDomain( b.getDomainId() );
1795 cd0.addCombinableDomain( b.getDomainId() );
1796 cd0.addCombinableDomain( c.getDomainId() );
1797 cd0.addCombinableDomain( c.getDomainId() );
1798 cd0.addCombinableDomain( c.getDomainId() );
1799 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
1802 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
1805 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
1808 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
1811 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
1814 if ( cd0.getAllDomains().size() != 4 ) {
1817 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
1820 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
1823 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
1826 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
1829 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
1832 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "key0", "a" );
1833 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "key0" );
1834 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "key0", "c" );
1835 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "key0", "cc" );
1836 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "c", "key0" );
1837 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
1840 if ( !cd0.toBinaryDomainCombinations().contains( s1 ) ) {
1843 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
1846 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
1849 if ( !cd0.toBinaryDomainCombinations().contains( s4 ) ) {
1852 final Domain key1 = new BasicDomain( "key1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1853 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1854 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1855 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1856 final CombinableDomains cd1 = new BasicCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
1857 cd1.addCombinableDomain( a1.getDomainId() );
1858 cd1.addCombinableDomain( b1.getDomainId() );
1859 cd1.addCombinableDomain( c1.getDomainId() );
1860 cd1.addCombinableDomain( key1.getDomainId() );
1861 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
1864 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
1867 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
1870 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
1873 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
1876 if ( cd1.getAllDomains().size() != 4 ) {
1879 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
1882 final BasicBinaryDomainCombination kk = new BasicBinaryDomainCombination( "key1", "key1" );
1883 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
1887 catch ( final Exception e ) {
1888 e.printStackTrace( System.out );
1894 private static boolean testCombinationsBasedPairwiseSimilarityCalculator() {
1896 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1897 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1898 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1899 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1900 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1901 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1902 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1903 new BasicSpecies( "rabbit" ) );
1904 one.addCombinableDomain( a.getDomainId() );
1905 one.addCombinableDomain( a.getDomainId() );
1906 two.addCombinableDomain( new BasicDomain( "A", 1, 5, ( short ) 1, ( short ) 4, 0.1, -12 ).getDomainId() );
1907 two.addCombinableDomain( b.getDomainId() );
1908 two.addCombinableDomain( c.getDomainId() );
1909 final PairwiseDomainSimilarityCalculator calc = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1910 final PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1911 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 / ( 1 + 2 ) ) ) {
1914 if ( s1.getDifferenceInCounts() != ( 1 - 3 ) ) {
1917 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s1 ).getNumberOfDifferentDomains() != 2 ) {
1920 one.addCombinableDomain( b.getDomainId() );
1921 one.addCombinableDomain( c.getDomainId() );
1922 final PairwiseDomainSimilarity s2 = calc.calculateSimilarity( one, two );
1923 if ( !TestSurfacing.isEqual( s2.getSimilarityScore(), 3.0 / ( 0 + 3 ) ) ) {
1926 if ( s2.getDifferenceInCounts() != 0 ) {
1929 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s2 ).getNumberOfDifferentDomains() != 0 ) {
1932 final Domain d = new BasicDomain( "D", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1933 final Domain e = new BasicDomain( "E", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1934 final Domain f = new BasicDomain( "F", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1935 one.addCombinableDomain( d.getDomainId() );
1936 one.addCombinableDomain( d.getDomainId() );
1937 one.addCombinableDomain( e.getDomainId() );
1938 one.addCombinableDomain( f.getDomainId() );
1939 final PairwiseDomainSimilarity s3 = calc.calculateSimilarity( one, two );
1940 if ( !TestSurfacing.isEqual( s3.getSimilarityScore(), 3.0 / ( 3 + 3 ) ) ) {
1943 if ( s3.getDifferenceInCounts() != ( 6 - 3 ) ) {
1946 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s3 ).getNumberOfDifferentDomains() != 3 ) {
1949 final Domain aaa = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1950 final Domain bbb = new BasicDomain( "bbb", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1951 final Domain three_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1952 final Domain four_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1953 final CombinableDomains three = new BasicCombinableDomains( three_key.getDomainId(),
1954 new BasicSpecies( "mouse" ) );
1955 final CombinableDomains four = new BasicCombinableDomains( four_key.getDomainId(),
1956 new BasicSpecies( "rabbit" ) );
1957 three.addCombinableDomain( aaa.getDomainId() );
1958 four.addCombinableDomain( bbb.getDomainId() );
1959 final PairwiseDomainSimilarityCalculator calc2 = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1960 final PairwiseDomainSimilarity s4 = calc2.calculateSimilarity( three, four );
1961 if ( !TestSurfacing.isEqual( s4.getSimilarityScore(), 0.0 / ( 0 + 2 ) ) ) {
1964 final Domain aaa2 = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1965 four.addCombinableDomain( aaa2.getDomainId() );
1966 final PairwiseDomainSimilarity s5 = calc.calculateSimilarity( three, four );
1967 if ( !TestSurfacing.isEqual( s5.getSimilarityScore(), 1.0 / ( 1 + 1 ) ) ) {
1971 catch ( final Exception e ) {
1972 e.printStackTrace( System.out );
1978 private static boolean testCopyNumberBasedPairwiseSimilarityCalculator() {
1980 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1981 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1982 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1983 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1984 new BasicSpecies( "rabbit" ) );
1985 one.setKeyDomainCount( 2 );
1986 two.setKeyDomainCount( 3 );
1987 final PairwiseDomainSimilarityCalculator calc = new DomainCountsBasedPairwiseSimilarityCalculator();
1988 PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1989 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 3 - 2.0 ) / ( 2 + 3 ) ) ) {
1992 if ( s1.getDifferenceInCounts() != ( 2 - 3 ) ) {
1995 one.setKeyDomainCount( 1 );
1996 two.setKeyDomainCount( 1 );
1997 s1 = calc.calculateSimilarity( one, two );
1998 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 ) ) {
2001 if ( s1.getDifferenceInCounts() != ( 1 - 1 ) ) {
2004 one.setKeyDomainCount( 1 );
2005 two.setKeyDomainCount( 1000 );
2006 s1 = calc.calculateSimilarity( one, two );
2007 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - 999.0 / 1001 ) ) {
2010 if ( s1.getDifferenceInCounts() != ( 1 - 1000 ) ) {
2014 catch ( final Exception e ) {
2015 e.printStackTrace( System.out );
2021 private static boolean testDirectedCombinableDomains() {
2023 final Domain key0 = new BasicDomain( "key0", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 );
2024 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2025 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2026 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2027 final CombinableDomains cd0 = new DirectedCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
2028 cd0.addCombinableDomain( a.getDomainId() );
2029 cd0.addCombinableDomain( b.getDomainId() );
2030 cd0.addCombinableDomain( b.getDomainId() );
2031 cd0.addCombinableDomain( c.getDomainId() );
2032 cd0.addCombinableDomain( c.getDomainId() );
2033 cd0.addCombinableDomain( c.getDomainId() );
2034 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
2037 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
2040 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
2043 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
2046 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
2049 if ( cd0.getAllDomains().size() != 4 ) {
2052 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
2055 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
2058 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
2061 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
2064 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
2067 final BinaryDomainCombination s0 = new DirectedBinaryDomainCombination( "key0", "a" );
2068 final BinaryDomainCombination s1 = new DirectedBinaryDomainCombination( "b", "key0" );
2069 final BinaryDomainCombination s2 = new DirectedBinaryDomainCombination( "key0", "c" );
2070 final BinaryDomainCombination s3 = new DirectedBinaryDomainCombination( "key0", "cc" );
2071 final BinaryDomainCombination s4 = new DirectedBinaryDomainCombination( "a", "b" );
2072 final BinaryDomainCombination s5 = new DirectedBinaryDomainCombination( "b", "a" );
2073 final BinaryDomainCombination s6 = new DirectedBinaryDomainCombination( "key0", "b" );
2074 final BinaryDomainCombination s7 = new DirectedBinaryDomainCombination( "a", "key0" );
2075 final BinaryDomainCombination s8 = new DirectedBinaryDomainCombination( "c", "key0" );
2076 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
2079 if ( cd0.toBinaryDomainCombinations().contains( s1 ) ) {
2082 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
2085 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
2088 if ( cd0.toBinaryDomainCombinations().contains( s4 ) ) {
2091 if ( cd0.toBinaryDomainCombinations().contains( s5 ) ) {
2094 if ( !cd0.toBinaryDomainCombinations().contains( s6 ) ) {
2097 if ( cd0.toBinaryDomainCombinations().contains( s7 ) ) {
2100 if ( cd0.toBinaryDomainCombinations().contains( s8 ) ) {
2103 final Domain key1 = new BasicDomain( "key1", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 );
2104 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2105 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2106 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2107 final CombinableDomains cd1 = new DirectedCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
2108 cd1.addCombinableDomain( a1.getDomainId() );
2109 cd1.addCombinableDomain( b1.getDomainId() );
2110 cd1.addCombinableDomain( c1.getDomainId() );
2111 cd1.addCombinableDomain( key1.getDomainId() );
2112 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
2115 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
2118 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
2121 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
2124 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
2127 if ( cd1.getAllDomains().size() != 4 ) {
2130 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
2133 final BinaryDomainCombination kk = new DirectedBinaryDomainCombination( "key1", "key1" );
2134 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
2138 catch ( final Exception e ) {
2139 e.printStackTrace( System.out );
2145 private static boolean testDirectedness() {
2147 final BinaryStates X = BinaryStates.PRESENT;
2148 final BinaryStates O = BinaryStates.ABSENT;
2149 final GainLossStates G = GainLossStates.GAIN;
2150 final GainLossStates L = GainLossStates.LOSS;
2151 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
2152 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
2153 final Protein one_1 = new BasicProtein( "one", "1" );
2154 final Protein two_1 = new BasicProtein( "two", "1" );
2155 final Protein three_1 = new BasicProtein( "three", "1" );
2156 final Protein four_1 = new BasicProtein( "four", "1" );
2157 final Protein five_1 = new BasicProtein( "five", "1" );
2158 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2159 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2160 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2161 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2162 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2163 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2164 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2165 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2166 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2167 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2168 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2169 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2170 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2171 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2172 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2173 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2174 final List<Protein> list_1 = new ArrayList<Protein>();
2175 list_1.add( one_1 );
2176 list_1.add( two_1 );
2177 list_1.add( three_1 );
2178 list_1.add( four_1 );
2179 list_1.add( five_1 );
2180 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2181 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED );
2182 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "B" ) ) ) {
2185 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "A" ) ) ) {
2188 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "A" ) ) ) {
2191 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "C" ) ) ) {
2194 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "A" ) ) ) {
2197 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "C" ) ) ) {
2200 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "X" ) ) ) {
2203 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2206 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
2209 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2212 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2215 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "A" ) ) ) {
2218 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "B" ) ) ) {
2221 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2224 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2227 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2230 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
2233 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2236 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "N" ) ) ) {
2239 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "M" ) ) ) {
2242 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "P" ) ) ) {
2245 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "P" ) ) ) {
2248 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "N" ) ) ) {
2251 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "M" ) ) ) {
2254 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2257 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2260 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "B" ) ) ) {
2263 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
2264 // gwcd_list.add( gwcd_1 );
2265 // gwcd_list.add( gwcd_2 );
2266 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
2267 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
2268 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
2269 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
2270 // if ( matrix_d.getState( 0, 0 ) != X ) {
2273 // if ( matrix_bc.getState( 0, 0 ) != X ) {
2278 // final BasicCharacterStateMatrix<BinaryStates> dm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
2279 // { X, X, X, X, X, X }, { X, X, X, X, X, X } } );
2280 // if ( !matrix_d.equals( dm ) ) {
2283 // final BasicCharacterStateMatrix<BinaryStates> bcm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
2284 // { X, O, X, X, X, X, O, X, X, O, X, X }, { X, X, X, O, O, O, O, X, O, O, X, X } } );
2285 // if ( !matrix_d.equals( dm ) ) {
2288 //``````````````````````````
2289 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
2290 // gwcd_list.add( one );
2291 // gwcd_list.add( two );
2292 // gwcd_list.add( three );
2293 // gwcd_list.add( four );
2294 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimony
2295 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
2296 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimony
2297 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
2298 // // System.out.println( "d:" );
2299 // // System.out.println(matrix_d.toStringBuffer().toString() );
2300 // // System.out.println( "bc:" );
2301 // // System.out.println(matrix_bc.toStringBuffer().toString() );
2302 // // 1 a b c e f g h l m
2303 // // 2 a b c e f g i n o
2304 // // 3 a b d e f g j p q
2306 // if ( matrix_d.getState( 0, 0 ) != X ) {
2309 // if ( matrix_d.getState( 0, 1 ) != X ) {
2312 // if ( matrix_d.getState( 0, 2 ) != X ) {
2315 // if ( matrix_d.getState( 0, 3 ) != O ) {
2318 // if ( matrix_d.getState( 0, 4 ) != X ) {
2321 // if ( matrix_d.getState( 0, 5 ) != X ) {
2324 // if ( matrix_d.getState( 0, 6 ) != X ) {
2327 // if ( matrix_d.getState( 0, 7 ) != X ) {
2330 // if ( matrix_d.getState( 0, 8 ) != O ) {
2333 // // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
2334 // // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
2335 // // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
2337 // if ( matrix_bc.getState( 0, 0 ) != X ) {
2340 // if ( matrix_bc.getState( 0, 1 ) != X ) {
2343 // if ( matrix_bc.getState( 0, 2 ) != X ) {
2346 // if ( matrix_bc.getState( 0, 3 ) != O ) {
2349 // if ( matrix_bc.getState( 0, 4 ) != X ) {
2352 // if ( matrix_bc.getState( 1, 0 ) != O ) {
2355 // if ( matrix_bc.getState( 1, 1 ) != X ) {
2358 // if ( matrix_bc.getState( 1, 2 ) != X ) {
2361 // if ( matrix_bc.getState( 1, 3 ) != O ) {
2364 // if ( matrix_bc.getState( 1, 4 ) != X ) {
2367 // if ( matrix_bc.getState( 2, 0 ) != O ) {
2370 // if ( matrix_bc.getState( 2, 1 ) != X ) {
2373 // if ( matrix_bc.getState( 2, 2 ) != O ) {
2376 // if ( matrix_bc.getState( 2, 3 ) != X ) {
2379 // if ( matrix_bc.getState( 2, 4 ) != X ) {
2382 // final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
2383 // final String p0_str = "((one,two)1-2,(three,four)3-4)root";
2384 // final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
2385 // final DomainParsimony dp0 = DomainParsimony.createInstance( p0, gwcd_list );
2386 // dp0.executeDolloParsimonyOnDomainPresence();
2387 // final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
2388 // final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
2389 // dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2390 // final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
2391 // final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
2392 // if ( is_matrix_d.getState( "root", "A" ) != X ) {
2395 // if ( is_matrix_d.getState( "root", "B" ) != X ) {
2398 // if ( is_matrix_d.getState( "root", "C" ) != O ) {
2401 // if ( is_matrix_d.getState( "root", "D" ) != O ) {
2404 // if ( is_matrix_d.getState( "root", "E" ) != X ) {
2407 // if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
2410 // if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
2413 // if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
2416 // if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
2419 // if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
2422 // if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
2425 // if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
2428 // if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
2431 // if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
2434 // if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
2437 // if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
2440 // if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
2443 // if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
2446 // if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
2449 // final Protein ab_1 = new BasicProtein( "ab", "one" );
2450 // ab_1.addProteinDomain( a );
2451 // ab_1.addProteinDomain( b );
2452 // final Protein ac_1 = new BasicProtein( "ac", "one" );
2453 // ac_1.addProteinDomain( a );
2454 // ac_1.addProteinDomain( c );
2455 // final Protein de_1 = new BasicProtein( "de", "one" );
2456 // de_1.addProteinDomain( d );
2457 // de_1.addProteinDomain( e );
2458 // final Protein ac_2 = new BasicProtein( "ac", "two" );
2459 // ac_2.addProteinDomain( a );
2460 // ac_2.addProteinDomain( c );
2461 // final Protein ab_3 = new BasicProtein( "ab", "three" );
2462 // ab_3.addProteinDomain( a );
2463 // ab_3.addProteinDomain( b );
2464 // final Protein de_4 = new BasicProtein( "de", "four" );
2465 // de_4.addProteinDomain( d );
2466 // de_4.addProteinDomain( e );
2467 // final Protein ab_6 = new BasicProtein( "ab", "six" );
2468 // ab_6.addProteinDomain( a );
2469 // ab_6.addProteinDomain( b );
2470 // final List<Protein> spec_one = new ArrayList<Protein>();
2471 // final List<Protein> spec_two = new ArrayList<Protein>();
2472 // final List<Protein> spec_three = new ArrayList<Protein>();
2473 // final List<Protein> spec_four = new ArrayList<Protein>();
2474 // final List<Protein> spec_five = new ArrayList<Protein>();
2475 // final List<Protein> spec_six = new ArrayList<Protein>();
2476 // final List<Protein> spec_seven = new ArrayList<Protein>();
2477 // spec_one.add( ab_1 );
2478 // spec_one.add( ac_1 );
2479 // spec_one.add( de_1 );
2480 // spec_two.add( ac_2 );
2481 // spec_three.add( ab_3 );
2482 // spec_four.add( de_4 );
2483 // spec_six.add( ab_6 );
2484 // final GenomeWideCombinableDomains one_gwcd = BasicGenomeWideCombinableDomains
2485 // .createInstance( spec_one, false, new BasicSpecies( "one" ), false );
2486 // final GenomeWideCombinableDomains two_gwcd = BasicGenomeWideCombinableDomains
2487 // .createInstance( spec_two, false, new BasicSpecies( "two" ), false );
2488 // final GenomeWideCombinableDomains three_gwcd = BasicGenomeWideCombinableDomains
2489 // .createInstance( spec_three, false, new BasicSpecies( "three" ), false );
2490 // final GenomeWideCombinableDomains four_gwcd = BasicGenomeWideCombinableDomains
2491 // .createInstance( spec_four, false, new BasicSpecies( "four" ), false );
2492 // final GenomeWideCombinableDomains five_gwcd = BasicGenomeWideCombinableDomains
2493 // .createInstance( spec_five, false, new BasicSpecies( "five" ), false );
2494 // final GenomeWideCombinableDomains six_gwcd = BasicGenomeWideCombinableDomains
2495 // .createInstance( spec_six, false, new BasicSpecies( "six" ), false );
2496 // final GenomeWideCombinableDomains seven_gwcd = BasicGenomeWideCombinableDomains
2497 // .createInstance( spec_seven, false, new BasicSpecies( "seven" ), false
2499 // final List<GenomeWideCombinableDomains> gwcd_list1 = new ArrayList<GenomeWideCombinableDomains>();
2500 // gwcd_list1.add( one_gwcd );
2501 // gwcd_list1.add( two_gwcd );
2502 // gwcd_list1.add( three_gwcd );
2503 // gwcd_list1.add( four_gwcd );
2504 // gwcd_list1.add( five_gwcd );
2505 // gwcd_list1.add( six_gwcd );
2506 // gwcd_list1.add( seven_gwcd );
2507 // final PhylogenyFactory factory1 = ParserBasedPhylogenyFactory.getInstance();
2508 // final String p1_str = "(((((one,two)12,three)123,(four,five)45)12345,six)123456,seven)root";
2509 // final Phylogeny p1 = factory1.create( p1_str, new NHXParser() )[ 0 ];
2510 // final DomainParsimony dp1 = DomainParsimony.createInstance( p1, gwcd_list1 );
2511 // dp1.executeDolloParsimonyOnDomainPresence();
2512 // final CharacterStateMatrix<GainLossStates> gl_dollo_d = dp1.getGainLossMatrix();
2513 // final CharacterStateMatrix<BinaryStates> i_dollo_d = dp1.getInternalStatesMatrix();
2514 // if ( dp1.getCost() != 14 ) {
2517 // if ( dp1.getTotalGains() != 5 ) {
2520 // if ( dp1.getTotalLosses() != 9 ) {
2523 // if ( dp1.getTotalUnchanged() != 51 ) {
2526 // if ( dp1.getNetGainsOnNode( "45" ) != -2 ) {
2529 // if ( dp1.getSumOfGainsOnNode( "45" ) != 0 ) {
2532 // if ( dp1.getSumOfLossesOnNode( "45" ) != 2 ) {
2535 // if ( dp1.getSumOfUnchangedOnNode( "45" ) != 3 ) {
2538 // if ( dp1.getSumOfUnchangedPresentOnNode( "45" ) != 2 ) {
2541 // if ( dp1.getSumOfUnchangedAbsentOnNode( "45" ) != 1 ) {
2544 // if ( dp1.getUnitsGainedOnNode( "45" ).contains( "A" ) ) {
2547 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A" ) ) {
2550 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "B" ) ) {
2553 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D" ) ) {
2556 // if ( !dp1.getUnitsOnNode( "12" ).contains( "A" ) ) {
2559 // if ( !dp1.getUnitsOnNode( "12" ).contains( "B" ) ) {
2562 // if ( !dp1.getUnitsOnNode( "12" ).contains( "C" ) ) {
2565 // if ( !dp1.getUnitsOnNode( "12" ).contains( "D" ) ) {
2568 // if ( !dp1.getUnitsOnNode( "12" ).contains( "E" ) ) {
2571 // if ( dp1.getNetGainsOnNode( "123456" ) != 2 ) {
2574 // if ( dp1.getSumOfGainsOnNode( "123456" ) != 2 ) {
2577 // dp1.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2578 // final CharacterStateMatrix<GainLossStates> gl_dollo_bc = dp1.getGainLossMatrix();
2579 // final CharacterStateMatrix<BinaryStates> i_dollo_bc = dp1.getInternalStatesMatrix();
2580 // if ( dp1.getCost() != 8 ) {
2583 // if ( dp1.getTotalGains() != 3 ) {
2586 // if ( dp1.getTotalLosses() != 5 ) {
2589 // if ( dp1.getTotalUnchanged() != 31 ) {
2592 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2595 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D=E" ) ) {
2598 // dp1.executeFitchParsimonyOnDomainPresence();
2599 // final CharacterStateMatrix<GainLossStates> gl_fitch_d = dp1.getGainLossMatrix();
2600 // final CharacterStateMatrix<BinaryStates> i_fitch_d = dp1.getInternalStatesMatrix();
2601 // if ( dp1.getCost() != 10 ) {
2604 // if ( dp1.getTotalGains() != 7 ) {
2607 // if ( dp1.getTotalLosses() != 3 ) {
2610 // if ( dp1.getTotalUnchanged() != 55 ) {
2613 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "E" ) ) {
2616 // dp1.executeFitchParsimonyOnBinaryDomainCombintion();
2617 // final CharacterStateMatrix<GainLossStates> gl_fitch_bc = dp1.getGainLossMatrix();
2618 // final CharacterStateMatrix<BinaryStates> i_fitch_bc = dp1.getInternalStatesMatrix();
2619 // if ( dp1.getCost() != 6 ) {
2622 // if ( dp1.getTotalGains() != 4 ) {
2625 // if ( dp1.getTotalLosses() != 2 ) {
2628 // if ( dp1.getTotalUnchanged() != 33 ) {
2631 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2634 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "D=E" ) ) {
2637 // if ( dp1.getNetGainsOnNode( "two" ) != -1 ) {
2640 // if ( dp1.getNetGainsOnNode( "123" ) != 0 ) {
2643 // if ( dp1.getSumOfUnchangedPresentOnNode( "123" ) != 1 ) {
2646 // if ( dp1.getSumOfUnchangedAbsentOnNode( "123" ) != 2 ) {
2649 // if ( dp1.getSumOfUnchangedOnNode( "123" ) != 3 ) {
2652 // if ( dp1.getSumOfUnchangedOnNode( "two" ) != 2 ) {
2655 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "two" ).contains( "D=E" ) ) {
2658 // if ( !dp1.getUnitsUnchangedPresentOnNode( "two" ).contains( "A=C" ) ) {
2661 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "A=C" ) ) {
2664 // if ( !dp1.getUnitsUnchangedPresentOnNode( "123" ).contains( "A=B" ) ) {
2667 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "D=E" ) ) {
2670 // CharacterStateMatrix<BinaryStates> bsm = null;
2671 // CharacterStateMatrix<GainLossStates> glm = null;
2672 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, X, X },
2673 // { 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 } } );
2674 // if ( !bsm.equals( i_dollo_d ) ) {
2677 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, O, O },
2678 // { 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 } } );
2679 // if ( !bsm.equals( i_fitch_d ) ) {
2682 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, P, P },
2683 // { 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 },
2684 // { 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 },
2685 // { A, A, A, A, A }, { A, A, A, A, A } } );
2686 // if ( !glm.equals( gl_dollo_d ) ) {
2689 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, G, G },
2690 // { 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 },
2691 // { 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 },
2692 // { A, A, A, A, A }, { A, A, A, A, A } } );
2693 // if ( !glm.equals( gl_fitch_d ) ) {
2696 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X }, { X, O, X },
2697 // { O, O, X }, { X, O, X }, { X, O, O }, { O, O, O } } );
2698 // if ( !bsm.equals( i_dollo_bc ) ) {
2701 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, O }, { X, O, O },
2702 // { O, O, O }, { X, O, O }, { X, O, O }, { O, O, O } } );
2703 // if ( !bsm.equals( i_fitch_bc ) ) {
2706 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P }, { L, P, L },
2707 // { P, G, P }, { P, A, L }, { P, A, P }, { A, A, P }, { A, A, L }, { L, A, P }, { P, A, G },
2708 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2709 // if ( !glm.equals( gl_dollo_bc ) ) {
2712 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, G }, { L, P, A },
2713 // { P, G, A }, { P, A, A }, { P, A, A }, { A, A, G }, { A, A, A }, { L, A, A }, { P, A, A },
2714 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2715 // if ( !glm.equals( gl_fitch_bc ) ) {
2719 catch ( final Exception e ) {
2720 e.printStackTrace( System.out );
2726 private static boolean testDirectednessAndAdjacency() {
2728 final Protein one_1 = new BasicProtein( "one", "1" );
2729 final Protein two_1 = new BasicProtein( "two", "1" );
2730 final Protein three_1 = new BasicProtein( "three", "1" );
2731 final Protein four_1 = new BasicProtein( "four", "1" );
2732 final Protein five_1 = new BasicProtein( "five", "1" );
2733 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2734 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2735 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2736 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2737 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2738 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2739 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2740 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2741 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2742 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2743 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2744 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2745 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2746 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2747 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2748 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2749 final List<Protein> list_1 = new ArrayList<Protein>();
2750 list_1.add( one_1 );
2751 list_1.add( two_1 );
2752 list_1.add( three_1 );
2753 list_1.add( four_1 );
2754 list_1.add( five_1 );
2755 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2756 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED_ADJACTANT );
2757 if ( !gwcd_1.toBinaryDomainCombinations()
2758 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "B" ) ) ) {
2761 if ( gwcd_1.toBinaryDomainCombinations()
2762 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "A" ) ) ) {
2765 if ( gwcd_1.toBinaryDomainCombinations()
2766 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "A" ) ) ) {
2769 if ( gwcd_1.toBinaryDomainCombinations()
2770 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "C" ) ) ) {
2773 if ( gwcd_1.toBinaryDomainCombinations()
2774 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "A" ) ) ) {
2777 if ( !gwcd_1.toBinaryDomainCombinations()
2778 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "C" ) ) ) {
2781 if ( !gwcd_1.toBinaryDomainCombinations()
2782 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "X" ) ) ) {
2785 if ( gwcd_1.toBinaryDomainCombinations()
2786 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2789 if ( !gwcd_1.toBinaryDomainCombinations()
2790 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2793 if ( gwcd_1.toBinaryDomainCombinations()
2794 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2797 if ( gwcd_1.toBinaryDomainCombinations()
2798 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2801 if ( !gwcd_1.toBinaryDomainCombinations()
2802 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2805 if ( gwcd_1.toBinaryDomainCombinations()
2806 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "A" ) ) ) {
2809 if ( gwcd_1.toBinaryDomainCombinations()
2810 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "B" ) ) ) {
2813 if ( !gwcd_1.toBinaryDomainCombinations()
2814 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2817 if ( gwcd_1.toBinaryDomainCombinations()
2818 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2821 if ( gwcd_1.toBinaryDomainCombinations()
2822 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2825 if ( gwcd_1.toBinaryDomainCombinations()
2826 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2829 if ( gwcd_1.toBinaryDomainCombinations()
2830 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2833 if ( !gwcd_1.toBinaryDomainCombinations()
2834 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "N" ) ) ) {
2837 if ( !gwcd_1.toBinaryDomainCombinations()
2838 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "M" ) ) ) {
2841 if ( !gwcd_1.toBinaryDomainCombinations()
2842 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "P" ) ) ) {
2845 if ( gwcd_1.toBinaryDomainCombinations()
2846 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "P" ) ) ) {
2849 if ( gwcd_1.toBinaryDomainCombinations()
2850 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "N" ) ) ) {
2853 if ( gwcd_1.toBinaryDomainCombinations()
2854 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "M" ) ) ) {
2857 if ( gwcd_1.toBinaryDomainCombinations()
2858 .contains( new AdjactantDirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2861 if ( gwcd_1.toBinaryDomainCombinations()
2862 .contains( new AdjactantDirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2865 if ( gwcd_1.toBinaryDomainCombinations()
2866 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "B" ) ) ) {
2870 catch ( final Exception e ) {
2871 e.printStackTrace( System.out );
2877 private static boolean testDomainArchitectureBasedGenomeSimilarityCalculator() {
2879 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2880 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2881 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2882 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2883 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2884 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2885 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2886 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2887 final Domain i = new BasicDomain( "i", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2888 final Domain j = new BasicDomain( "j", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2889 final Domain k = new BasicDomain( "k", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2890 final Domain l = new BasicDomain( "l", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2891 final Domain m = new BasicDomain( "m", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2892 final Domain n = new BasicDomain( "n", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2893 final Protein eel_0 = new BasicProtein( "0", "eel" );
2894 final Protein eel_1 = new BasicProtein( "1", "eel" );
2895 final Protein eel_2 = new BasicProtein( "2", "eel" );
2896 final Protein eel_3 = new BasicProtein( "3", "eel" );
2897 final Protein eel_4 = new BasicProtein( "4", "eel" );
2898 final Protein eel_5 = new BasicProtein( "5", "eel" );
2899 final Protein eel_6 = new BasicProtein( "6", "eel" );
2900 final Protein rat_0 = new BasicProtein( "0", "rat" );
2901 final Protein rat_1 = new BasicProtein( "1", "rat" );
2902 final Protein rat_2 = new BasicProtein( "2", "rat" );
2903 final Protein rat_3 = new BasicProtein( "3", "rat" );
2904 final Protein rat_4 = new BasicProtein( "4", "rat" );
2905 final Protein rat_5 = new BasicProtein( "5", "rat" );
2906 final Protein rat_6 = new BasicProtein( "6", "rat" );
2907 final Protein rat_7 = new BasicProtein( "7", "rat" );
2908 eel_1.addProteinDomain( a );
2909 eel_2.addProteinDomain( a );
2910 eel_2.addProteinDomain( b );
2911 eel_3.addProteinDomain( a );
2912 eel_3.addProteinDomain( a );
2913 eel_3.addProteinDomain( b );
2914 eel_4.addProteinDomain( a );
2915 eel_4.addProteinDomain( b );
2916 eel_4.addProteinDomain( c );
2917 eel_4.addProteinDomain( d );
2918 eel_4.addProteinDomain( e );
2919 eel_5.addProteinDomain( e );
2920 eel_5.addProteinDomain( e );
2921 eel_5.addProteinDomain( f );
2922 eel_5.addProteinDomain( f );
2923 eel_5.addProteinDomain( f );
2924 eel_5.addProteinDomain( f );
2925 eel_6.addProteinDomain( g );
2926 eel_6.addProteinDomain( h );
2927 rat_1.addProteinDomain( a );
2928 rat_2.addProteinDomain( a );
2929 rat_2.addProteinDomain( b );
2930 rat_3.addProteinDomain( a );
2931 rat_3.addProteinDomain( a );
2932 rat_3.addProteinDomain( b );
2933 rat_4.addProteinDomain( a );
2934 rat_4.addProteinDomain( b );
2935 rat_4.addProteinDomain( c );
2936 rat_4.addProteinDomain( i );
2937 rat_4.addProteinDomain( l );
2938 rat_5.addProteinDomain( i );
2939 rat_5.addProteinDomain( f );
2940 rat_5.addProteinDomain( f );
2941 rat_6.addProteinDomain( j );
2942 rat_6.addProteinDomain( k );
2943 rat_7.addProteinDomain( m );
2944 rat_7.addProteinDomain( n );
2945 final List<Protein> protein_list_eel = new ArrayList<Protein>();
2946 protein_list_eel.add( eel_0 );
2947 protein_list_eel.add( eel_1 );
2948 protein_list_eel.add( eel_2 );
2949 protein_list_eel.add( eel_3 );
2950 protein_list_eel.add( eel_4 );
2951 protein_list_eel.add( eel_5 );
2952 protein_list_eel.add( eel_6 );
2953 final List<Protein> protein_list_rat = new ArrayList<Protein>();
2954 protein_list_rat.add( rat_0 );
2955 protein_list_rat.add( rat_1 );
2956 protein_list_rat.add( rat_2 );
2957 protein_list_rat.add( rat_3 );
2958 protein_list_rat.add( rat_4 );
2959 protein_list_rat.add( rat_5 );
2960 protein_list_rat.add( rat_6 );
2961 protein_list_rat.add( rat_7 );
2962 final GenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
2963 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
2964 final GenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
2965 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
2966 final GenomeWideCombinableDomains rat_not_ignore = BasicGenomeWideCombinableDomains
2967 .createInstance( protein_list_rat, false, new BasicSpecies( "rat" ) );
2968 final GenomeWideCombinableDomains rat_ignore = BasicGenomeWideCombinableDomains
2969 .createInstance( protein_list_rat, true, new BasicSpecies( "rat" ) );
2970 final DomainArchitectureBasedGenomeSimilarityCalculator calc_ni = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_not_ignore,
2972 final DomainArchitectureBasedGenomeSimilarityCalculator calc_i = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_ignore,
2974 if ( calc_ni.getAllDomains().size() != 14 ) {
2977 if ( calc_i.getAllDomains().size() != 14 ) {
2980 if ( calc_ni.getDomainsSpecificToGenome0().size() != 4 ) {
2983 if ( calc_i.getDomainsSpecificToGenome0().size() != 4 ) {
2986 if ( calc_ni.getDomainsSpecificToGenome1().size() != 6 ) {
2989 if ( calc_i.getDomainsSpecificToGenome1().size() != 6 ) {
2992 if ( calc_i.getSharedDomains().size() != 4 ) {
2995 if ( calc_ni.getSharedDomains().size() != 4 ) {
2998 if ( !calc_ni.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
3001 if ( !calc_ni.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
3004 if ( !calc_ni.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
3007 if ( !calc_ni.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
3010 if ( calc_ni.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
3013 if ( calc_ni.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
3016 if ( !calc_i.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
3019 if ( !calc_i.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
3022 if ( !calc_i.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
3025 if ( !calc_i.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
3028 if ( calc_i.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
3031 if ( calc_i.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
3034 if ( !calc_ni.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
3037 if ( !calc_ni.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
3040 if ( !calc_ni.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
3043 if ( !calc_ni.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
3046 if ( !calc_ni.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
3049 if ( !calc_ni.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
3052 if ( calc_ni.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
3055 if ( calc_ni.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
3058 if ( calc_ni.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
3061 if ( !calc_i.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
3064 if ( !calc_i.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
3067 if ( !calc_i.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
3070 if ( !calc_i.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
3073 if ( !calc_i.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
3076 if ( !calc_i.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
3079 if ( calc_i.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
3082 if ( calc_i.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
3085 if ( calc_i.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
3088 if ( !calc_i.getSharedDomains().contains( a.getDomainId() ) ) {
3091 if ( !calc_i.getSharedDomains().contains( b.getDomainId() ) ) {
3094 if ( !calc_i.getSharedDomains().contains( c.getDomainId() ) ) {
3097 if ( !calc_i.getSharedDomains().contains( f.getDomainId() ) ) {
3100 final Set<DomainId> all = calc_ni.getAllDomains();
3101 if ( !all.contains( a.getDomainId() ) ) {
3104 if ( !all.contains( b.getDomainId() ) ) {
3107 if ( !all.contains( c.getDomainId() ) ) {
3110 if ( !all.contains( d.getDomainId() ) ) {
3113 if ( !all.contains( e.getDomainId() ) ) {
3116 if ( !all.contains( f.getDomainId() ) ) {
3119 if ( !all.contains( g.getDomainId() ) ) {
3122 if ( !all.contains( h.getDomainId() ) ) {
3125 if ( !all.contains( i.getDomainId() ) ) {
3128 if ( !all.contains( l.getDomainId() ) ) {
3131 if ( !all.contains( j.getDomainId() ) ) {
3134 if ( !all.contains( k.getDomainId() ) ) {
3137 if ( !all.contains( m.getDomainId() ) ) {
3140 if ( !all.contains( n.getDomainId() ) ) {
3143 final Set<BinaryDomainCombination> s_0_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome0();
3144 final Set<BinaryDomainCombination> s_0_i = calc_i.getBinaryDomainCombinationsSpecificToGenome0();
3145 final Set<BinaryDomainCombination> s_1_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome1();
3146 final Set<BinaryDomainCombination> s_1_i = calc_i.getBinaryDomainCombinationsSpecificToGenome1();
3147 final Set<BinaryDomainCombination> a_ni = calc_ni.getAllBinaryDomainCombinations();
3148 final Set<BinaryDomainCombination> a_i = calc_i.getAllBinaryDomainCombinations();
3149 final Set<BinaryDomainCombination> shared_ni = calc_ni.getSharedBinaryDomainCombinations();
3150 final Set<BinaryDomainCombination> shared_i = calc_i.getSharedBinaryDomainCombinations();
3151 if ( a_ni.size() != 25 ) {
3154 if ( a_i.size() != 22 ) {
3157 if ( s_0_ni.size() != 10 ) {
3160 if ( s_0_i.size() != 9 ) {
3163 if ( s_1_ni.size() != 10 ) {
3166 if ( s_1_i.size() != 10 ) {
3169 if ( shared_ni.size() != 5 ) {
3172 if ( shared_i.size() != 3 ) {
3175 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3178 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
3181 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3184 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3187 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3190 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3193 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3196 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3199 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3202 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3205 if ( !a_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3208 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3211 if ( !a_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3214 if ( !a_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3217 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3220 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3223 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3226 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3229 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3232 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3235 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3238 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "l" ) ) ) {
3241 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3244 if ( !a_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3247 if ( !a_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3250 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
3253 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "m" ) ) ) {
3256 if ( a_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3259 if ( a_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3262 if ( a_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3265 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3268 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3271 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3274 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3277 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3280 if ( shared_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3283 if ( shared_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3286 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3289 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3292 if ( !shared_i.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3295 if ( shared_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3298 if ( shared_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3301 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3304 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3307 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3310 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3313 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3316 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3319 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3322 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3325 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3328 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3331 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3334 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3337 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3340 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3343 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3346 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3349 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3352 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3355 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3358 if ( s_0_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3361 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3364 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3367 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3370 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3373 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3376 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3379 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3382 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3385 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3388 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3391 if ( s_1_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3394 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3397 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3400 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3403 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3406 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3409 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3412 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3415 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3418 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3421 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3424 if ( s_1_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3427 if ( !isEqual( calc_ni.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3428 1.0 - ( 25.0 - 5.0 ) / 25.0 ) ) {
3431 if ( !isEqual( calc_i.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3432 1.0 - ( 22.0 - 3.0 ) / 22.0 ) ) {
3435 if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
3438 if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
3441 final Domain u = new BasicDomain( "u", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3442 final Domain v = new BasicDomain( "v", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3443 final Domain w = new BasicDomain( "w", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3444 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3445 final Domain y = new BasicDomain( "y", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3446 final Domain z = new BasicDomain( "z", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3447 final Protein a_0 = new BasicProtein( "0", "a" );
3448 final Protein a_1 = new BasicProtein( "1", "a" );
3449 final Protein a_2 = new BasicProtein( "2", "a" );
3450 final Protein b_0 = new BasicProtein( "0", "b" );
3451 final Protein b_1 = new BasicProtein( "1", "b" );
3452 a_0.addProteinDomain( u );
3453 a_0.addProteinDomain( v );
3454 a_0.addProteinDomain( w );
3455 a_1.addProteinDomain( w );
3456 a_1.addProteinDomain( x );
3457 a_2.addProteinDomain( y );
3458 a_2.addProteinDomain( z );
3459 b_0.addProteinDomain( u );
3460 b_0.addProteinDomain( w );
3461 b_1.addProteinDomain( y );
3462 b_1.addProteinDomain( z );
3463 final List<Protein> protein_list_a = new ArrayList<Protein>();
3464 protein_list_a.add( a_0 );
3465 protein_list_a.add( a_1 );
3466 protein_list_a.add( a_2 );
3467 final List<Protein> protein_list_b = new ArrayList<Protein>();
3468 protein_list_b.add( b_0 );
3469 protein_list_b.add( b_1 );
3470 final GenomeWideCombinableDomains ca = BasicGenomeWideCombinableDomains
3471 .createInstance( protein_list_a, false, new BasicSpecies( "a" ) );
3472 final GenomeWideCombinableDomains cb = BasicGenomeWideCombinableDomains
3473 .createInstance( protein_list_b, true, new BasicSpecies( "b" ) );
3474 final DomainArchitectureBasedGenomeSimilarityCalculator calc_u = new DomainArchitectureBasedGenomeSimilarityCalculator( ca,
3476 calc_u.setAllowDomainsToBeIgnored( true );
3477 if ( calc_u.getAllDomains().size() != 6 ) {
3480 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3483 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3486 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3489 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3492 if ( calc_u.getSharedDomains().size() != 4 ) {
3495 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3498 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3501 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3504 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3507 if ( calc_u.getAllDomains().size() != 6 ) {
3510 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3513 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3516 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3519 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3522 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3525 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3528 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 3 ) {
3531 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3534 if ( calc_u.getSharedBinaryDomainCombinations().size() != 2 ) {
3537 if ( calc_u.getAllBinaryDomainCombinations().size() != 5 ) {
3540 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3541 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3544 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3545 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3548 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3549 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3552 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3555 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3558 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3561 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3564 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3567 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3570 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3573 calc_u.setAllowDomainsToBeIgnored( true );
3574 calc_u.addDomainIdToIgnore( u.getDomainId() );
3575 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3576 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3577 if ( calc_u.getAllDomains().size() != 5 ) {
3580 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3583 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3586 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3589 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3592 if ( calc_u.getSharedDomains().size() != 3 ) {
3595 if ( calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3598 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3601 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3604 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3607 if ( calc_u.getAllDomains().size() != 5 ) {
3610 if ( calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3613 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3616 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3619 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3622 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3625 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3628 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 2 ) {
3631 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3634 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3637 if ( calc_u.getAllBinaryDomainCombinations().size() != 3 ) {
3640 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3641 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3644 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3645 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3648 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3649 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3652 if ( calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3655 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3658 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3661 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3664 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3667 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3670 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3673 calc_u.setAllowDomainsToBeIgnored( false );
3674 if ( calc_u.getAllDomains().size() != 6 ) {
3678 calc_u.setAllowDomainsToBeIgnored( true );
3679 calc_u.deleteAllDomainIdsToIgnore();
3680 calc_u.addDomainIdToIgnore( new DomainId( "v" ) );
3681 calc_u.addDomainIdToIgnore( new DomainId( "w" ) );
3682 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3683 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3684 if ( calc_u.getAllDomains().size() != 4 ) {
3687 if ( calc_u.getDomainsSpecificToGenome0().size() != 1 ) {
3690 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3693 if ( calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3696 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3699 if ( calc_u.getSharedDomains().size() != 3 ) {
3702 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3705 if ( calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3708 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3711 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3714 if ( calc_u.getAllDomains().size() != 4 ) {
3717 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3720 if ( calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3723 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3726 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3729 if ( calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3732 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3735 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 0 ) {
3738 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3741 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3744 if ( calc_u.getAllBinaryDomainCombinations().size() != 1 ) {
3747 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "y", "z" ) ) ) {
3750 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3753 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3754 1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
3757 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
3760 calc_u.setAllowDomainsToBeIgnored( false );
3761 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3762 1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
3765 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
3768 calc_u.setAllowDomainsToBeIgnored( true );
3769 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3770 1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
3773 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
3776 calc_u.deleteAllDomainIdsToIgnore();
3777 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3778 1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
3781 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
3785 catch ( final Exception e ) {
3786 e.printStackTrace( System.out );
3792 private static boolean testDomainCombinationCounting( final File test_dir ) {
3794 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
3795 + ForesterUtil.getFileSeparator() + "hmmpfam_output2" ), "human", "ls" );
3796 parser.setEValueMaximum( 0.2 );
3797 parser.setIgnoreDufs( true );
3798 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
3799 final List<Protein> domain_collections = parser.parse();
3800 final BasicGenomeWideCombinableDomains cdcc = BasicGenomeWideCombinableDomains
3801 .createInstance( domain_collections, false, new BasicSpecies( "human" ) );
3802 CombinableDomains cd = cdcc.get( new DomainId( "A" ) );
3803 if ( cd.getKeyDomainCount() != 9 ) {
3806 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3809 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3812 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 2 ) {
3815 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
3818 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3821 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3824 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3827 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3830 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3833 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3836 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3839 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3842 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3845 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3848 if ( cd.getKeyDomainCount() != 9 ) {
3851 cd = cdcc.get( new DomainId( "B" ) );
3852 if ( cd.getKeyDomainCount() != 12 ) {
3855 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3858 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3861 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 6 ) {
3864 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3867 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3870 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3873 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3876 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3879 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3882 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3885 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3888 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3891 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3894 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3897 if ( cd.getKeyDomainCount() != 12 ) {
3900 cd = cdcc.get( new DomainId( "C" ) );
3901 if ( cd.getKeyDomainCount() != 10 ) {
3904 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3907 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3910 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 4 ) {
3913 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3916 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 2 ) {
3919 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3922 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3925 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3928 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3931 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3934 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 2 ) {
3937 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 2 ) {
3940 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 2 ) {
3943 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3946 cd = cdcc.get( new DomainId( "D" ) );
3947 if ( cd.getKeyDomainCount() != 15 ) {
3950 if ( cd.getKeyDomainProteinsCount() != 6 ) {
3953 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3956 cd = cdcc.get( new DomainId( "E" ) );
3957 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3960 if ( cd.getKeyDomainCount() != 1 ) {
3963 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3966 cd = cdcc.get( new DomainId( "U" ) );
3967 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3970 if ( cd.getKeyDomainCount() != 6 ) {
3973 if ( cd.getKeyDomainProteinsCount() != 3 ) {
3976 cd = cdcc.get( new DomainId( "V" ) );
3977 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3980 if ( cd.getKeyDomainCount() != 3 ) {
3983 if ( cd.getKeyDomainProteinsCount() != 2 ) {
3986 cd = cdcc.get( new DomainId( "W" ) );
3987 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3990 if ( cd.getKeyDomainCount() != 2 ) {
3993 if ( cd.getKeyDomainProteinsCount() != 2 ) {
3996 cd = cdcc.get( new DomainId( "X" ) );
3997 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4000 if ( cd.getKeyDomainCount() != 2 ) {
4003 cd = cdcc.get( new DomainId( "Y" ) );
4004 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4007 cd = cdcc.get( new DomainId( "Z" ) );
4008 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4011 cd = cdcc.get( new DomainId( "NN" ) );
4012 if ( cd.getKeyDomainCount() != 1 ) {
4015 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4018 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4021 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
4024 cd = cdcc.get( new DomainId( "MM" ) );
4025 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4028 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 0 ) {
4031 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
4034 cd = cdcc.get( new DomainId( "OO" ) );
4035 if ( cd.getNumberOfCombinableDomains() != 2 ) {
4038 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
4041 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 1 ) {
4044 cd = cdcc.get( new DomainId( "QQ" ) );
4045 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4048 if ( cd.getKeyDomainCount() != 17 ) {
4051 if ( cd.getKeyDomainProteinsCount() != 4 ) {
4054 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "QQ" ).getDomainId() ) != 3 ) {
4057 cd = cdcc.get( new DomainId( "PP" ) );
4058 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4061 if ( cd.getKeyDomainCount() != 2 ) {
4064 if ( cd.getKeyDomainProteinsCount() != 2 ) {
4067 cd = cdcc.get( new DomainId( "singlet" ) );
4068 if ( cd.getKeyDomainCount() != 1 ) {
4071 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4074 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4077 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "singlet" ).getDomainId() ) != 0 ) {
4080 cd = cdcc.get( new DomainId( "three" ) );
4081 if ( cd.getKeyDomainCount() != 3 ) {
4084 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4087 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4090 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 1 ) {
4093 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
4096 // Ignore combinations with same:
4097 final BasicGenomeWideCombinableDomains cdcc2 = BasicGenomeWideCombinableDomains
4098 .createInstance( domain_collections,
4100 new BasicSpecies( "human" ),
4102 DomainCombinationType.BASIC );
4103 cd = cdcc2.get( new DomainId( "A" ) );
4104 if ( cd.getKeyDomainCount() != 9 ) {
4107 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4110 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4113 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 0 ) {
4116 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
4119 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
4122 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
4125 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
4128 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4131 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4134 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4137 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
4140 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
4143 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
4146 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4149 cd = cdcc2.get( new DomainId( "B" ) );
4150 if ( cd.getKeyDomainCount() != 12 ) {
4153 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4156 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4159 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 6 ) {
4162 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 0 ) {
4165 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 4 ) {
4168 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
4171 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
4174 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4177 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4180 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4183 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
4186 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
4189 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
4192 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4195 cd = cdcc2.get( new DomainId( "C" ) );
4196 if ( cd.getKeyDomainCount() != 10 ) {
4199 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4202 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4205 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 4 ) {
4208 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 4 ) {
4211 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 0 ) {
4214 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
4217 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
4220 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4223 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4226 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4229 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 2 ) {
4232 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 2 ) {
4235 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 2 ) {
4238 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4241 cd = cdcc2.get( new DomainId( "D" ) );
4242 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4245 cd = cdcc2.get( new DomainId( "E" ) );
4246 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4249 if ( cd.getKeyDomainCount() != 1 ) {
4252 cd = cdcc2.get( new DomainId( "U" ) );
4253 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4256 cd = cdcc2.get( new DomainId( "V" ) );
4257 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4260 cd = cdcc2.get( new DomainId( "W" ) );
4261 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4264 cd = cdcc2.get( new DomainId( "X" ) );
4265 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4268 cd = cdcc2.get( new DomainId( "Y" ) );
4269 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4272 cd = cdcc2.get( new DomainId( "Z" ) );
4273 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4276 cd = cdcc2.get( new DomainId( "NN" ) );
4277 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4280 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4283 cd = cdcc2.get( new DomainId( "MM" ) );
4284 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4287 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 0 ) {
4290 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 1 ) {
4293 cd = cdcc2.get( new DomainId( "OO" ) );
4294 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4297 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 0 ) {
4300 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 1 ) {
4303 cd = cdcc2.get( new DomainId( "QQ" ) );
4304 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4307 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "QQ" ) ) != 0 ) {
4310 cd = cdcc2.get( new DomainId( "singlet" ) );
4311 if ( cd.getKeyDomainCount() != 1 ) {
4314 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4317 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4320 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "singlet" ) ) != 0 ) {
4323 cd = cdcc2.get( new DomainId( "three" ) );
4324 if ( cd.getKeyDomainCount() != 3 ) {
4327 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4330 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4333 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 0 ) {
4336 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
4340 catch ( final Exception e ) {
4341 e.printStackTrace( System.out );
4347 private static boolean testDomainId() {
4349 final DomainId id1 = new DomainId( "a" );
4350 final DomainId id2 = new DomainId( "a" );
4351 final DomainId id3 = new DomainId( "A" );
4352 final DomainId id4 = new DomainId( "b" );
4353 if ( !id1.equals( id1 ) ) {
4356 if ( id1.getId().equals( "x" ) ) {
4359 if ( id1.getId().equals( null ) ) {
4362 if ( !id1.equals( id2 ) ) {
4365 if ( id1.equals( id3 ) ) {
4368 if ( id1.hashCode() != id1.hashCode() ) {
4371 if ( id1.hashCode() != id2.hashCode() ) {
4374 if ( id1.hashCode() == id3.hashCode() ) {
4377 if ( id1.compareTo( id1 ) != 0 ) {
4380 if ( id1.compareTo( id2 ) != 0 ) {
4383 if ( id1.compareTo( id3 ) != 0 ) {
4386 if ( id1.compareTo( id4 ) >= 0 ) {
4389 if ( id4.compareTo( id1 ) <= 0 ) {
4392 if ( !id4.getId().equals( "b" ) ) {
4395 final DomainId id5 = new DomainId( " C " );
4396 if ( !id5.getId().equals( "C" ) ) {
4399 if ( id5.equals( id1 ) ) {
4403 catch ( final Exception e ) {
4404 e.printStackTrace( System.out );
4410 private static boolean testDomainSorting() {
4412 final Domain A = new BasicDomain( "A", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4413 final Domain B = new BasicDomain( "B", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4414 final Domain C = new BasicDomain( "C", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.2, -12 );
4415 final Domain D = new BasicDomain( "D", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.3, -12 );
4416 final Domain E = new BasicDomain( "E", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.4, -12 );
4417 final Domain F = new BasicDomain( "F", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.5, -12 );
4418 final Domain G = new BasicDomain( "G", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.6, -12 );
4419 final Domain H1 = new BasicDomain( "H", ( short ) 100, ( short ) 200, ( short ) 1, ( short ) 5, 0.7, -12 );
4420 final Domain H2 = new BasicDomain( "H", ( short ) 300, ( short ) 400, ( short ) 2, ( short ) 5, 0.7, -12 );
4421 final Domain H3 = new BasicDomain( "H", ( short ) 500, ( short ) 600, ( short ) 3, ( short ) 5, 0.7, -12 );
4422 final Domain H4 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 4, ( short ) 5, 0.7, -12 );
4423 final Domain H5 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4424 final Domain H6 = new BasicDomain( "H",
4431 final Domain H7 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4432 final Domain H8 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 200, 0.7, -12 );
4433 final Protein protein = new BasicProtein( "00", "bat" );
4434 protein.addProteinDomain( H5 );
4435 protein.addProteinDomain( H2 );
4436 protein.addProteinDomain( H7 );
4437 protein.addProteinDomain( H6 );
4438 protein.addProteinDomain( A );
4439 protein.addProteinDomain( G );
4440 protein.addProteinDomain( H4 );
4441 protein.addProteinDomain( D );
4442 protein.addProteinDomain( H1 );
4443 protein.addProteinDomain( C );
4444 protein.addProteinDomain( E );
4445 protein.addProteinDomain( F );
4446 protein.addProteinDomain( B );
4447 protein.addProteinDomain( H3 );
4448 protein.addProteinDomain( H7 );
4449 protein.addProteinDomain( H7 );
4450 protein.addProteinDomain( H8 );
4451 final List<Domain> sorted = SurfacingUtil.sortDomainsWithAscendingConfidenceValues( protein );
4452 if ( sorted.size() != 17 ) {
4455 if ( !sorted.get( 0 ).getDomainId().getId().equals( "A" ) ) {
4458 if ( sorted.get( 0 ).getNumber() != 1 ) {
4461 if ( !sorted.get( 1 ).getDomainId().getId().equals( "B" ) ) {
4464 if ( sorted.get( 1 ).getNumber() != 1 ) {
4467 if ( !sorted.get( 2 ).getDomainId().getId().equals( "C" ) ) {
4470 if ( sorted.get( 2 ).getNumber() != 1 ) {
4473 if ( !sorted.get( 3 ).getDomainId().getId().equals( "D" ) ) {
4476 if ( sorted.get( 3 ).getNumber() != 1 ) {
4479 if ( !sorted.get( 4 ).getDomainId().getId().equals( "E" ) ) {
4482 if ( sorted.get( 4 ).getNumber() != 1 ) {
4485 if ( !sorted.get( 5 ).getDomainId().getId().equals( "F" ) ) {
4488 if ( sorted.get( 5 ).getNumber() != 1 ) {
4491 if ( !sorted.get( 6 ).getDomainId().getId().equals( "G" ) ) {
4494 if ( sorted.get( 6 ).getNumber() != 1 ) {
4497 if ( !sorted.get( 7 ).getDomainId().getId().equals( "H" ) ) {
4500 if ( sorted.get( 7 ).getNumber() != 5 ) {
4503 if ( !sorted.get( 8 ).getDomainId().getId().equals( "H" ) ) {
4506 if ( sorted.get( 8 ).getNumber() != 2 ) {
4509 if ( !sorted.get( 9 ).getDomainId().getId().equals( "H" ) ) {
4512 if ( sorted.get( 9 ).getNumber() != 6 ) {
4515 if ( !sorted.get( 10 ).getDomainId().getId().equals( "H" ) ) {
4518 if ( sorted.get( 10 ).getNumber() != 4 ) {
4521 if ( !sorted.get( 11 ).getDomainId().getId().equals( "H" ) ) {
4524 if ( sorted.get( 11 ).getNumber() != 1 ) {
4527 if ( sorted.get( 11 ).getTotalCount() != 5 ) {
4530 if ( !sorted.get( 12 ).getDomainId().getId().equals( "H" ) ) {
4533 if ( sorted.get( 12 ).getNumber() != 3 ) {
4536 if ( !sorted.get( 13 ).getDomainId().getId().equals( "H7" ) ) {
4539 if ( sorted.get( 13 ).getNumber() != 5 ) {
4542 if ( !sorted.get( 14 ).getDomainId().getId().equals( "H7" ) ) {
4545 if ( sorted.get( 14 ).getNumber() != 5 ) {
4548 if ( !sorted.get( 15 ).getDomainId().getId().equals( "H7" ) ) {
4551 if ( sorted.get( 15 ).getNumber() != 5 ) {
4554 // To check if sorting is stable [as claimed by Sun for
4555 // Collections.sort( List )]
4556 if ( !sorted.get( 16 ).getDomainId().getId().equals( "H7" ) ) {
4559 if ( sorted.get( 16 ).getNumber() != 5 ) {
4562 if ( sorted.get( 16 ).getTotalCount() != 200 ) {
4566 catch ( final Exception e ) {
4567 e.printStackTrace( System.out );
4573 private static boolean testEngulfingOverlapRemoval() {
4575 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4576 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
4577 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
4578 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4579 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4580 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4581 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
4582 final List<Boolean> covered = new ArrayList<Boolean>();
4583 covered.add( true ); // 0
4584 covered.add( false ); // 1
4585 covered.add( true ); // 2
4586 covered.add( false ); // 3
4587 covered.add( true ); // 4
4588 covered.add( true ); // 5
4589 covered.add( false ); // 6
4590 covered.add( true ); // 7
4591 covered.add( true ); // 8
4592 if ( SurfacingUtil.isEngulfed( d0, covered ) ) {
4595 if ( SurfacingUtil.isEngulfed( d1, covered ) ) {
4598 if ( SurfacingUtil.isEngulfed( d2, covered ) ) {
4601 if ( !SurfacingUtil.isEngulfed( d3, covered ) ) {
4604 if ( SurfacingUtil.isEngulfed( d4, covered ) ) {
4607 if ( SurfacingUtil.isEngulfed( d5, covered ) ) {
4610 if ( !SurfacingUtil.isEngulfed( d6, covered ) ) {
4613 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4614 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
4615 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
4616 final Protein abc = new BasicProtein( "abc", "nemve" );
4617 abc.addProteinDomain( a );
4618 abc.addProteinDomain( b );
4619 abc.addProteinDomain( c );
4620 final Protein abc_r1 = SurfacingUtil.removeOverlappingDomains( 3, false, abc );
4621 final Protein abc_r2 = SurfacingUtil.removeOverlappingDomains( 3, true, abc );
4622 if ( abc.getNumberOfProteinDomains() != 3 ) {
4625 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
4628 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
4631 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
4634 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "b" ) ) {
4637 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4638 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
4639 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
4640 final Protein def = new BasicProtein( "def", "nemve" );
4641 def.addProteinDomain( d );
4642 def.addProteinDomain( e );
4643 def.addProteinDomain( f );
4644 final Protein def_r1 = SurfacingUtil.removeOverlappingDomains( 5, false, def );
4645 final Protein def_r2 = SurfacingUtil.removeOverlappingDomains( 5, true, def );
4646 if ( def.getNumberOfProteinDomains() != 3 ) {
4649 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
4652 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
4655 if ( !def_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "d" ) ) {
4658 if ( !def_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "f" ) ) {
4661 if ( !def_r2.getProteinDomain( 2 ).getDomainId().getId().equals( "e" ) ) {
4665 catch ( final Exception e ) {
4666 e.printStackTrace( System.out );
4672 private static boolean testGenomeWideCombinableDomains() {
4674 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4675 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4676 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4677 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4678 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4679 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4680 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4681 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4682 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4683 final Protein eel_0 = new BasicProtein( "0", "eel" );
4684 final Protein eel_1 = new BasicProtein( "1", "eel" );
4685 final Protein eel_2 = new BasicProtein( "2", "eel" );
4686 final Protein eel_3 = new BasicProtein( "3", "eel" );
4687 final Protein eel_4 = new BasicProtein( "4", "eel" );
4688 final Protein eel_5 = new BasicProtein( "5", "eel" );
4689 final Protein eel_6 = new BasicProtein( "6", "eel" );
4690 eel_1.addProteinDomain( a );
4691 eel_2.addProteinDomain( a );
4692 eel_2.addProteinDomain( b );
4693 eel_3.addProteinDomain( a );
4694 eel_3.addProteinDomain( a );
4695 eel_3.addProteinDomain( b );
4696 eel_4.addProteinDomain( a );
4697 eel_4.addProteinDomain( b );
4698 eel_4.addProteinDomain( c );
4699 eel_4.addProteinDomain( d );
4700 eel_4.addProteinDomain( e );
4701 eel_5.addProteinDomain( e );
4702 eel_5.addProteinDomain( e );
4703 eel_5.addProteinDomain( f );
4704 eel_5.addProteinDomain( f );
4705 eel_5.addProteinDomain( f );
4706 eel_5.addProteinDomain( f );
4707 eel_6.addProteinDomain( g );
4708 eel_6.addProteinDomain( h );
4709 final List<Protein> protein_list_eel = new ArrayList<Protein>();
4710 protein_list_eel.add( eel_0 );
4711 protein_list_eel.add( eel_1 );
4712 protein_list_eel.add( eel_2 );
4713 protein_list_eel.add( eel_3 );
4714 protein_list_eel.add( eel_4 );
4715 protein_list_eel.add( eel_5 );
4716 protein_list_eel.add( eel_6 );
4717 final BasicGenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
4718 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
4719 final BasicGenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
4720 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
4721 if ( !eel_not_ignore.contains( new DomainId( "a" ) ) ) {
4724 if ( !eel_not_ignore.contains( new DomainId( "b" ) ) ) {
4727 if ( !eel_not_ignore.contains( new DomainId( "c" ) ) ) {
4730 if ( !eel_not_ignore.contains( new DomainId( "d" ) ) ) {
4733 if ( !eel_not_ignore.contains( new DomainId( "e" ) ) ) {
4736 if ( !eel_not_ignore.contains( new DomainId( "f" ) ) ) {
4739 if ( !eel_not_ignore.contains( new DomainId( "g" ) ) ) {
4742 if ( !eel_not_ignore.contains( new DomainId( "h" ) ) ) {
4745 if ( eel_not_ignore.contains( new DomainId( "x" ) ) ) {
4748 if ( !eel_ignore.contains( new DomainId( "a" ) ) ) {
4751 if ( !eel_ignore.contains( new DomainId( "b" ) ) ) {
4754 if ( !eel_ignore.contains( new DomainId( "c" ) ) ) {
4757 if ( !eel_ignore.contains( new DomainId( "d" ) ) ) {
4760 if ( !eel_ignore.contains( new DomainId( "e" ) ) ) {
4763 if ( !eel_ignore.contains( new DomainId( "f" ) ) ) {
4766 if ( !eel_ignore.contains( new DomainId( "g" ) ) ) {
4769 if ( !eel_ignore.contains( new DomainId( "h" ) ) ) {
4772 if ( eel_ignore.contains( new DomainId( "x" ) ) ) {
4775 if ( eel_not_ignore.getSize() != 8 ) {
4778 if ( eel_ignore.getSize() != 8 ) {
4781 if ( eel_not_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 5 ) {
4784 if ( eel_not_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4787 if ( eel_not_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4790 if ( eel_not_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4793 if ( eel_not_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 6 ) {
4796 if ( eel_not_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 2 ) {
4799 if ( eel_not_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4802 if ( eel_not_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4805 if ( eel_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 4 ) {
4808 if ( eel_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4811 if ( eel_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4814 if ( eel_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4817 if ( eel_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 5 ) {
4820 if ( eel_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 1 ) {
4823 if ( eel_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4826 if ( eel_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4829 if ( eel_not_ignore.getAllDomainIds().size() != 8 ) {
4832 if ( !eel_not_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4835 if ( !eel_not_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4838 if ( !eel_not_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4841 if ( !eel_not_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4844 if ( !eel_not_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4847 if ( !eel_not_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4850 if ( !eel_not_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4853 if ( !eel_not_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4856 if ( eel_not_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4859 if ( eel_ignore.getAllDomainIds().size() != 8 ) {
4862 if ( !eel_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4865 if ( !eel_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4868 if ( !eel_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4871 if ( !eel_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4874 if ( !eel_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4877 if ( !eel_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4880 if ( !eel_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4883 if ( !eel_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4886 if ( eel_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4889 final SortedSet<BinaryDomainCombination> bc0 = eel_not_ignore.toBinaryDomainCombinations();
4890 if ( bc0.size() != 15 ) {
4893 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4896 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4899 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4902 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4905 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4908 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4911 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4914 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4917 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4920 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4923 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
4926 if ( !bc0.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
4929 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
4932 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
4935 if ( !bc0.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
4938 if ( !bc0.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
4941 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
4944 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
4947 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "h" ) ) ) {
4950 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
4953 final SortedSet<BinaryDomainCombination> bc1 = eel_ignore.toBinaryDomainCombinations();
4954 if ( bc1.size() != 12 ) {
4957 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4960 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4963 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4966 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4969 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4972 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4975 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4978 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4981 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4984 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4987 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
4990 if ( !bc1.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
4993 if ( !bc1.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
4996 if ( !bc1.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
4999 if ( bc1.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
5002 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
5005 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
5008 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
5011 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
5014 if ( bc1.contains( new BasicBinaryDomainCombination( "b", "g" ) ) ) {
5018 catch ( final Exception e ) {
5019 e.printStackTrace( System.out );
5025 private static boolean testHmmPfamOutputParser( final File test_dir ) {
5027 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
5028 + ForesterUtil.getFileSeparator() + "hmmpfam_output" ), "human", "ls" );
5029 parser.setEValueMaximum( 0.2 );
5030 parser.setIgnoreDufs( true );
5031 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5032 List<?> domain_collections = null;
5033 domain_collections = parser.parse();
5034 if ( parser.getDomainsEncountered() != 4 ) {
5037 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
5040 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
5043 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
5046 if ( parser.getDomainsStored() != 3 ) {
5049 if ( domain_collections.size() != 1 ) {
5052 final Protein pdc = ( Protein ) domain_collections.get( 0 );
5053 if ( !pdc.getProteinId().equals( new ProteinId( "ENSP00000285681" ) ) ) {
5056 if ( !pdc.getSpecies().getSpeciesId().equals( "human" ) ) {
5059 if ( pdc.getNumberOfProteinDomains() != 3 ) {
5062 if ( !pdc.getAccession().equals( "acc_ENSP00000285681" ) ) {
5067 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
5070 final List<Domain> uba = pdc.getProteinDomains( new DomainId( "UBA" ) );
5071 final List<Domain> uim = pdc.getProteinDomains( new DomainId( "UIM" ) );
5072 final List<Domain> uch = pdc.getProteinDomains( new DomainId( "UCH" ) );
5073 if ( uba.size() != 1 ) {
5076 if ( uim.size() != 2 ) {
5079 if ( uch.size() != 0 ) {
5082 final BasicDomain uim_domain = ( BasicDomain ) uim.get( 1 );
5083 if ( !uim_domain.getDomainId().equals( new DomainId( "UIM" ) ) ) {
5086 if ( uim_domain.getTotalCount() != 2 ) {
5089 final BasicDomain uba_domain = ( BasicDomain ) uba.get( 0 );
5090 if ( !uba_domain.getDomainId().equals( new DomainId( "UBA" ) ) ) {
5093 if ( uba_domain.getNumber() != 1 ) {
5096 if ( uba_domain.getTotalCount() != 1 ) {
5099 if ( uba_domain.getFrom() != 16 ) {
5102 if ( uba_domain.getTo() != 57 ) {
5105 if ( !Test.isEqual( uba_domain.getPerSequenceEvalue(), 0.00084 ) ) {
5108 if ( !Test.isEqual( uba_domain.getPerSequenceScore(), 23.2 ) ) {
5111 final HmmPfamOutputParser parser2 = new HmmPfamOutputParser( new File( test_dir
5112 + ForesterUtil.getFileSeparator() + "hmmpfam_output_short" ), "human", "ls" );
5113 parser2.setEValueMaximum( 0.2 );
5114 parser2.setIgnoreDufs( true );
5115 parser2.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5116 List<Protein> domain_collections2 = null;
5117 domain_collections2 = parser2.parse();
5118 if ( parser2.getDomainsEncountered() != 4 ) {
5121 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
5124 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
5127 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
5130 if ( parser2.getDomainsStored() != 3 ) {
5133 if ( domain_collections2.size() != 1 ) {
5136 final Protein pdc2 = domain_collections2.get( 0 );
5137 if ( !pdc2.getProteinId().getId().equals( "ENSP00000285681" ) ) {
5140 if ( !pdc2.getSpecies().getSpeciesId().equals( "human" ) ) {
5143 if ( !pdc2.getName().equals( "" ) ) {
5146 if ( !pdc2.getAccession().equals( "223" ) ) {
5151 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
5154 if ( pdc2.getNumberOfProteinDomains() != 3 ) {
5157 final List<Domain> uba2 = pdc2.getProteinDomains( new DomainId( "UBA" ) );
5158 final List<Domain> uim2 = pdc2.getProteinDomains( new DomainId( "UIM" ) );
5159 final List<Domain> uch2 = pdc2.getProteinDomains( new DomainId( "UCH" ) );
5160 if ( uba2.size() != 1 ) {
5163 if ( uim2.size() != 2 ) {
5166 if ( uch2.size() != 0 ) {
5169 final BasicDomain uim_domain2 = ( BasicDomain ) uim2.get( 1 );
5170 if ( !uim_domain2.getDomainId().getId().equals( "UIM" ) ) {
5173 if ( uim_domain2.getTotalCount() != 2 ) {
5176 final BasicDomain uba_domain2 = ( BasicDomain ) uba2.get( 0 );
5177 if ( !uba_domain2.getDomainId().getId().equals( "UBA" ) ) {
5180 if ( uba_domain2.getNumber() != 1 ) {
5183 if ( uba_domain2.getTotalCount() != 1 ) {
5186 if ( uba_domain2.getFrom() != 16 ) {
5189 if ( uba_domain2.getTo() != 57 ) {
5192 if ( !Test.isEqual( uba_domain2.getPerSequenceEvalue(), 0.00084 ) ) {
5196 catch ( final Exception e ) {
5197 e.printStackTrace( System.out );
5203 private static boolean testHmmPfamOutputParserWithFilter( final File test_dir ) {
5205 HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator()
5206 + "hmmpfam_output3" ), "human", "ls" );
5207 parser.setEValueMaximum( 0.2 );
5208 parser.setIgnoreDufs( true );
5209 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5210 List<Protein> proteins = null;
5211 proteins = parser.parse();
5212 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5215 if ( proteins.size() != 4 ) {
5219 Set<DomainId> filter = new TreeSet<DomainId>();
5220 filter.add( new DomainId( "beauty" ) );
5221 filter.add( new DomainId( "strange" ) );
5222 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5226 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5227 parser.setEValueMaximum( 0.2 );
5228 parser.setIgnoreDufs( true );
5229 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5231 proteins = parser.parse();
5232 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5235 if ( proteins.size() != 4 ) {
5239 filter = new TreeSet<DomainId>();
5240 filter.add( new DomainId( "beauty" ) );
5241 filter.add( new DomainId( "strange" ) );
5242 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5246 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5247 parser.setEValueMaximum( 0.2 );
5248 parser.setIgnoreDufs( true );
5249 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5251 proteins = parser.parse();
5252 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
5255 if ( proteins.size() != 0 ) {
5259 filter = new TreeSet<DomainId>();
5260 filter.add( new DomainId( "UIM" ) );
5261 filter.add( new DomainId( "A" ) );
5262 filter.add( new DomainId( "C" ) );
5263 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5267 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5268 parser.setEValueMaximum( 0.2 );
5269 parser.setIgnoreDufs( true );
5270 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5272 proteins = parser.parse();
5273 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5276 if ( proteins.size() != 4 ) {
5280 filter = new TreeSet<DomainId>();
5281 filter.add( new DomainId( "UIM" ) );
5282 filter.add( new DomainId( "A" ) );
5283 filter.add( new DomainId( "C" ) );
5284 filter.add( new DomainId( "X" ) );
5285 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5289 HmmPfamOutputParser.FilterType.NEGATIVE_DOMAIN );
5290 parser.setEValueMaximum( 0.2 );
5291 parser.setIgnoreDufs( true );
5292 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5294 proteins = parser.parse();
5295 if ( parser.getDomainsIgnoredDueToNegativeDomainFilter() != 7 ) {
5298 if ( proteins.size() != 3 ) {
5302 filter = new TreeSet<DomainId>();
5303 filter.add( new DomainId( "UIM" ) );
5304 filter.add( new DomainId( "A" ) );
5305 filter.add( new DomainId( "C" ) );
5306 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5310 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5311 parser.setEValueMaximum( 0.2 );
5312 parser.setIgnoreDufs( true );
5313 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5315 proteins = parser.parse();
5316 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
5319 if ( proteins.size() != 0 ) {
5323 filter = new TreeSet<DomainId>();
5324 filter.add( new DomainId( "UIM" ) );
5325 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5329 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5330 parser.setEValueMaximum( 0.2 );
5331 parser.setIgnoreDufs( true );
5332 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5334 proteins = parser.parse();
5335 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
5338 if ( parser.getProteinsStored() != 3 ) {
5341 if ( proteins.size() != 3 ) {
5345 filter = new TreeSet<DomainId>();
5346 filter.add( new DomainId( "UIM" ) );
5347 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5351 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5352 parser.setEValueMaximum( 0.2 );
5353 parser.setIgnoreDufs( true );
5354 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5356 proteins = parser.parse();
5357 if ( parser.getProteinsIgnoredDueToFilter() != 3 ) {
5360 if ( parser.getProteinsStored() != 1 ) {
5363 if ( proteins.size() != 1 ) {
5367 filter = new TreeSet<DomainId>();
5368 filter.add( new DomainId( "A" ) );
5369 filter.add( new DomainId( "C" ) );
5370 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5374 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5375 parser.setEValueMaximum( 0.2 );
5376 parser.setIgnoreDufs( true );
5377 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5379 proteins = parser.parse();
5380 if ( parser.getDomainsEncountered() != 11 ) {
5383 if ( parser.getProteinsEncountered() != 4 ) {
5386 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
5389 if ( parser.getProteinsStored() != 3 ) {
5392 if ( proteins.size() != 3 ) {
5396 catch ( final Exception e ) {
5397 e.printStackTrace( System.out );
5403 private static boolean testOverlapRemoval() {
5405 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
5406 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5407 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
5408 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5409 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
5410 final List<Boolean> covered = new ArrayList<Boolean>();
5411 covered.add( true ); // 0
5412 covered.add( false ); // 1
5413 covered.add( true ); // 2
5414 covered.add( false ); // 3
5415 covered.add( true ); // 4
5416 covered.add( true ); // 5
5417 covered.add( false ); // 6
5418 covered.add( true ); // 7
5419 covered.add( true ); // 8
5420 if ( SurfacingUtil.calculateOverlap( d0, covered ) != 3 ) {
5423 if ( SurfacingUtil.calculateOverlap( d1, covered ) != 2 ) {
5426 if ( SurfacingUtil.calculateOverlap( d2, covered ) != 6 ) {
5429 if ( SurfacingUtil.calculateOverlap( d3, covered ) != 0 ) {
5432 if ( SurfacingUtil.calculateOverlap( d4, covered ) != 2 ) {
5435 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.01, 1 );
5436 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5437 final Protein ab = new BasicProtein( "ab", "varanus" );
5438 ab.addProteinDomain( a );
5439 ab.addProteinDomain( b );
5440 final Protein ab_s0 = SurfacingUtil.removeOverlappingDomains( 3, false, ab );
5441 if ( ab.getNumberOfProteinDomains() != 2 ) {
5444 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
5447 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
5450 final Protein ab_s1 = SurfacingUtil.removeOverlappingDomains( 4, false, ab );
5451 if ( ab.getNumberOfProteinDomains() != 2 ) {
5454 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
5457 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
5458 final Domain d = new BasicDomain( "d",
5465 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
5466 final Protein cde = new BasicProtein( "cde", "varanus" );
5467 cde.addProteinDomain( c );
5468 cde.addProteinDomain( d );
5469 cde.addProteinDomain( e );
5470 final Protein cde_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, cde );
5471 if ( cde.getNumberOfProteinDomains() != 3 ) {
5474 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
5477 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5478 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5479 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5480 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
5481 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
5482 final Protein fghi = new BasicProtein( "fghi", "varanus" );
5483 fghi.addProteinDomain( f );
5484 fghi.addProteinDomain( g );
5485 fghi.addProteinDomain( h );
5486 fghi.addProteinDomain( i );
5487 fghi.addProteinDomain( i );
5488 fghi.addProteinDomain( i );
5489 fghi.addProteinDomain( i2 );
5490 final Protein fghi_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, fghi );
5491 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5494 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
5497 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "h" ) ) {
5500 final Protein fghi_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, fghi );
5501 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5504 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
5507 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5508 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5509 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5510 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
5511 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
5512 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
5513 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5514 final Protein jklm = new BasicProtein( "jklm", "varanus" );
5515 jklm.addProteinDomain( j );
5516 jklm.addProteinDomain( k );
5517 jklm.addProteinDomain( l );
5518 jklm.addProteinDomain( m );
5519 jklm.addProteinDomain( m0 );
5520 jklm.addProteinDomain( m1 );
5521 jklm.addProteinDomain( m2 );
5522 final Protein jklm_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, jklm );
5523 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5526 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
5529 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "l" ) ) {
5532 final Protein jklm_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, jklm );
5533 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5536 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
5539 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5540 final Protein od = new BasicProtein( "od", "varanus" );
5541 od.addProteinDomain( only );
5542 final Protein od_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, od );
5543 if ( od.getNumberOfProteinDomains() != 1 ) {
5546 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
5550 catch ( final Exception e ) {
5551 e.printStackTrace( System.out );
5557 private static boolean testParsimony() {
5559 final BinaryStates X = BinaryStates.PRESENT;
5560 final BinaryStates O = BinaryStates.ABSENT;
5561 final GainLossStates G = GainLossStates.GAIN;
5562 final GainLossStates L = GainLossStates.LOSS;
5563 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5564 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5565 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5566 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5567 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5568 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5569 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5570 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5571 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5572 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5573 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5574 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5575 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5576 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5577 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5578 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5579 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5580 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5581 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5582 // 1 a-a a-b a-c e-f-g-h l-m
5583 // 2 a-b a-c e-f-g-i n-o
5584 // 3 a-b a-d e-f-g-j p-q
5586 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5587 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5588 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5590 // 1 a b c e f g h l m
5591 // 2 a b c e f g i n o
5592 // 3 a b d e f g j p q
5594 final Protein aa1 = new BasicProtein( "aa1", "one" );
5595 aa1.addProteinDomain( a );
5596 aa1.addProteinDomain( a );
5597 final Protein ab1 = new BasicProtein( "ab1", "one" );
5598 ab1.addProteinDomain( a );
5599 ab1.addProteinDomain( b );
5600 final Protein ac1 = new BasicProtein( "ac1", "one" );
5601 ac1.addProteinDomain( a );
5602 ac1.addProteinDomain( c );
5603 final Protein efgh1 = new BasicProtein( "efgh1", "one" );
5604 efgh1.addProteinDomain( e );
5605 efgh1.addProteinDomain( f );
5606 efgh1.addProteinDomain( g );
5607 efgh1.addProteinDomain( h );
5608 final Protein lm1 = new BasicProtein( "lm1", "one" );
5609 lm1.addProteinDomain( l );
5610 lm1.addProteinDomain( m );
5611 final Protein ab2 = new BasicProtein( "ab2", "two" );
5612 ab2.addProteinDomain( a );
5613 ab2.addProteinDomain( b );
5614 final Protein ac2 = new BasicProtein( "ac2", "two" );
5615 ac2.addProteinDomain( a );
5616 ac2.addProteinDomain( c );
5617 final Protein efgi2 = new BasicProtein( "efgi2", "two" );
5618 efgi2.addProteinDomain( e );
5619 efgi2.addProteinDomain( f );
5620 efgi2.addProteinDomain( g );
5621 efgi2.addProteinDomain( i );
5622 final Protein no2 = new BasicProtein( "no2", "two" );
5623 no2.addProteinDomain( n );
5624 no2.addProteinDomain( o );
5625 final Protein ab3 = new BasicProtein( "ab3", "three" );
5626 ab3.addProteinDomain( a );
5627 ab3.addProteinDomain( b );
5628 final Protein ad3 = new BasicProtein( "ad3", "three" );
5629 ad3.addProteinDomain( a );
5630 ad3.addProteinDomain( d );
5631 final Protein efgj3 = new BasicProtein( "efgj3", "three" );
5632 efgj3.addProteinDomain( e );
5633 efgj3.addProteinDomain( f );
5634 efgj3.addProteinDomain( g );
5635 efgj3.addProteinDomain( j );
5636 final Protein pq3 = new BasicProtein( "pq3", "three" );
5637 pq3.addProteinDomain( p );
5638 pq3.addProteinDomain( q );
5639 final Protein ab4 = new BasicProtein( "ab4", "four" );
5640 ab4.addProteinDomain( a );
5641 ab4.addProteinDomain( b );
5642 final Protein ad4 = new BasicProtein( "ad4", "four" );
5643 ad4.addProteinDomain( a );
5644 ad4.addProteinDomain( d );
5645 final Protein pr4 = new BasicProtein( "pr4", "four" );
5646 pr4.addProteinDomain( p );
5647 pr4.addProteinDomain( r );
5648 final List<Protein> one_list = new ArrayList<Protein>();
5649 one_list.add( aa1 );
5650 one_list.add( ab1 );
5651 one_list.add( ac1 );
5652 one_list.add( efgh1 );
5653 one_list.add( lm1 );
5654 final List<Protein> two_list = new ArrayList<Protein>();
5655 two_list.add( ab2 );
5656 two_list.add( ac2 );
5657 two_list.add( efgi2 );
5658 two_list.add( no2 );
5659 final List<Protein> three_list = new ArrayList<Protein>();
5660 three_list.add( ab3 );
5661 three_list.add( ad3 );
5662 three_list.add( efgj3 );
5663 three_list.add( pq3 );
5664 final List<Protein> four_list = new ArrayList<Protein>();
5665 four_list.add( ab4 );
5666 four_list.add( ad4 );
5667 four_list.add( pr4 );
5668 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5669 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5670 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5671 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5672 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5673 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5674 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5675 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5676 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5677 gwcd_list.add( one );
5678 gwcd_list.add( two );
5679 gwcd_list.add( three );
5680 gwcd_list.add( four );
5681 final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
5682 .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
5683 final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
5684 .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
5685 // 1 a b c e f g h l m
5686 // 2 a b c e f g i n o
5687 // 3 a b d e f g j p q
5689 if ( matrix_d.getState( 0, 0 ) != X ) {
5692 if ( matrix_d.getState( 0, 1 ) != X ) {
5695 if ( matrix_d.getState( 0, 2 ) != X ) {
5698 if ( matrix_d.getState( 0, 3 ) != O ) {
5701 if ( matrix_d.getState( 0, 4 ) != X ) {
5704 if ( matrix_d.getState( 0, 5 ) != X ) {
5707 if ( matrix_d.getState( 0, 6 ) != X ) {
5710 if ( matrix_d.getState( 0, 7 ) != X ) {
5713 if ( matrix_d.getState( 0, 8 ) != O ) {
5716 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5717 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5718 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5720 if ( matrix_bc.getState( 0, 0 ) != X ) {
5723 if ( matrix_bc.getState( 0, 1 ) != X ) {
5726 if ( matrix_bc.getState( 0, 2 ) != X ) {
5729 if ( matrix_bc.getState( 0, 3 ) != O ) {
5732 if ( matrix_bc.getState( 0, 4 ) != X ) {
5735 if ( matrix_bc.getState( 1, 0 ) != O ) {
5738 if ( matrix_bc.getState( 1, 1 ) != X ) {
5741 if ( matrix_bc.getState( 1, 2 ) != X ) {
5744 if ( matrix_bc.getState( 1, 3 ) != O ) {
5747 if ( matrix_bc.getState( 1, 4 ) != X ) {
5750 if ( matrix_bc.getState( 2, 0 ) != O ) {
5753 if ( matrix_bc.getState( 2, 1 ) != X ) {
5756 if ( matrix_bc.getState( 2, 2 ) != O ) {
5759 if ( matrix_bc.getState( 2, 3 ) != X ) {
5762 if ( matrix_bc.getState( 2, 4 ) != X ) {
5765 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
5766 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
5767 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
5768 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list );
5769 dp0.executeDolloParsimonyOnDomainPresence();
5770 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
5771 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
5772 dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
5773 final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
5774 final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
5775 if ( is_matrix_d.getState( "root", "A" ) != X ) {
5778 if ( is_matrix_d.getState( "root", "B" ) != X ) {
5781 if ( is_matrix_d.getState( "root", "C" ) != O ) {
5784 if ( is_matrix_d.getState( "root", "D" ) != O ) {
5787 if ( is_matrix_d.getState( "root", "E" ) != X ) {
5790 if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
5793 if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
5796 if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
5799 if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
5802 if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
5805 if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
5808 if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
5811 if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
5814 if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
5817 if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
5820 if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
5823 if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
5826 if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
5829 if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
5833 catch ( final Exception e ) {
5834 e.printStackTrace( System.out );
5840 private static boolean testParsimonyOnSecondaryFeatures() {
5842 final BinaryStates X = BinaryStates.PRESENT;
5843 final BinaryStates O = BinaryStates.ABSENT;
5844 final GainLossStates G = GainLossStates.GAIN;
5845 final GainLossStates L = GainLossStates.LOSS;
5846 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5847 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5848 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5849 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5850 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5851 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5852 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5853 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5854 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5855 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5856 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5857 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5858 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5859 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5860 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5861 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5862 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5863 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5864 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5865 // 1 a-a a-b a-c e-f-g-h l-m
5866 // 2 a-b a-c e-f-g-i n-o
5867 // 3 a-b a-d e-f-g-j p-q
5869 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5870 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5871 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5873 // 1 a b c e f g h l m
5874 // 2 a b c e f g i n o
5875 // 3 a b d e f g j p q
5877 final Protein aa1 = new BasicProtein( "aa1", "one" );
5878 aa1.addProteinDomain( a );
5879 aa1.addProteinDomain( a );
5880 final Protein ab1 = new BasicProtein( "ab1", "one" );
5881 ab1.addProteinDomain( a );
5882 ab1.addProteinDomain( b );
5883 final Protein ac1 = new BasicProtein( "ac1", "one" );
5884 ac1.addProteinDomain( a );
5885 ac1.addProteinDomain( c );
5886 final Protein efgh1 = new BasicProtein( "efgh1", "one" );
5887 efgh1.addProteinDomain( e );
5888 efgh1.addProteinDomain( f );
5889 efgh1.addProteinDomain( g );
5890 efgh1.addProteinDomain( h );
5891 final Protein lm1 = new BasicProtein( "lm1", "one" );
5892 lm1.addProteinDomain( l );
5893 lm1.addProteinDomain( m );
5894 final Protein ab2 = new BasicProtein( "ab2", "two" );
5895 ab2.addProteinDomain( a );
5896 ab2.addProteinDomain( b );
5897 final Protein ac2 = new BasicProtein( "ac2", "two" );
5898 ac2.addProteinDomain( a );
5899 ac2.addProteinDomain( c );
5900 final Protein efgi2 = new BasicProtein( "efgi2", "two" );
5901 efgi2.addProteinDomain( e );
5902 efgi2.addProteinDomain( f );
5903 efgi2.addProteinDomain( g );
5904 efgi2.addProteinDomain( i );
5905 final Protein no2 = new BasicProtein( "no2", "two" );
5906 no2.addProteinDomain( n );
5907 no2.addProteinDomain( o );
5908 final Protein ab3 = new BasicProtein( "ab3", "three" );
5909 ab3.addProteinDomain( a );
5910 ab3.addProteinDomain( b );
5911 final Protein ad3 = new BasicProtein( "ad3", "three" );
5912 ad3.addProteinDomain( a );
5913 ad3.addProteinDomain( d );
5914 final Protein efgj3 = new BasicProtein( "efgj3", "three" );
5915 efgj3.addProteinDomain( e );
5916 efgj3.addProteinDomain( f );
5917 efgj3.addProteinDomain( g );
5918 efgj3.addProteinDomain( j );
5919 final Protein pq3 = new BasicProtein( "pq3", "three" );
5920 pq3.addProteinDomain( p );
5921 pq3.addProteinDomain( q );
5922 final Protein ab4 = new BasicProtein( "ab4", "four" );
5923 ab4.addProteinDomain( a );
5924 ab4.addProteinDomain( b );
5925 final Protein ad4 = new BasicProtein( "ad4", "four" );
5926 ad4.addProteinDomain( a );
5927 ad4.addProteinDomain( d );
5928 final Protein pr4 = new BasicProtein( "pr4", "four" );
5929 pr4.addProteinDomain( p );
5930 pr4.addProteinDomain( r );
5931 final List<Protein> one_list = new ArrayList<Protein>();
5932 one_list.add( aa1 );
5933 one_list.add( ab1 );
5934 one_list.add( ac1 );
5935 one_list.add( efgh1 );
5936 one_list.add( lm1 );
5937 final List<Protein> two_list = new ArrayList<Protein>();
5938 two_list.add( ab2 );
5939 two_list.add( ac2 );
5940 two_list.add( efgi2 );
5941 two_list.add( no2 );
5942 final List<Protein> three_list = new ArrayList<Protein>();
5943 three_list.add( ab3 );
5944 three_list.add( ad3 );
5945 three_list.add( efgj3 );
5946 three_list.add( pq3 );
5947 final List<Protein> four_list = new ArrayList<Protein>();
5948 four_list.add( ab4 );
5949 four_list.add( ad4 );
5950 four_list.add( pr4 );
5951 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5952 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5953 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5954 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5955 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5956 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5957 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5958 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5959 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5960 gwcd_list.add( one );
5961 gwcd_list.add( two );
5962 gwcd_list.add( three );
5963 gwcd_list.add( four );
5964 final Map<DomainId, Set<String>> map_same = new HashMap<DomainId, Set<String>>();
5965 final HashSet<String> a_s = new HashSet<String>();
5967 final HashSet<String> b_s = new HashSet<String>();
5969 final HashSet<String> c_s = new HashSet<String>();
5971 final HashSet<String> d_s = new HashSet<String>();
5973 final HashSet<String> e_s = new HashSet<String>();
5975 final HashSet<String> f_s = new HashSet<String>();
5977 final HashSet<String> g_s = new HashSet<String>();
5979 final HashSet<String> h_s = new HashSet<String>();
5981 final HashSet<String> i_s = new HashSet<String>();
5983 final HashSet<String> j_s = new HashSet<String>();
5985 final HashSet<String> l_s = new HashSet<String>();
5987 final HashSet<String> m_s = new HashSet<String>();
5989 final HashSet<String> n_s = new HashSet<String>();
5991 final HashSet<String> o_s = new HashSet<String>();
5993 final HashSet<String> p_s = new HashSet<String>();
5995 final HashSet<String> q_s = new HashSet<String>();
5997 final HashSet<String> r_s = new HashSet<String>();
5999 map_same.put( a.getDomainId(), a_s );
6000 map_same.put( b.getDomainId(), b_s );
6001 map_same.put( c.getDomainId(), c_s );
6002 map_same.put( d.getDomainId(), d_s );
6003 map_same.put( e.getDomainId(), e_s );
6004 map_same.put( f.getDomainId(), f_s );
6005 map_same.put( g.getDomainId(), g_s );
6006 map_same.put( h.getDomainId(), h_s );
6007 map_same.put( i.getDomainId(), i_s );
6008 map_same.put( j.getDomainId(), j_s );
6009 map_same.put( l.getDomainId(), l_s );
6010 map_same.put( m.getDomainId(), m_s );
6011 map_same.put( n.getDomainId(), n_s );
6012 map_same.put( o.getDomainId(), o_s );
6013 map_same.put( p.getDomainId(), p_s );
6014 map_same.put( q.getDomainId(), q_s );
6015 map_same.put( r.getDomainId(), r_s );
6016 final CharacterStateMatrix<BinaryStates> matrix_s = DomainParsimonyCalculator
6017 .createMatrixOfSecondaryFeaturePresenceOrAbsence( gwcd_list, map_same, null );
6018 // 1 a b c e f g h l m
6019 // 2 a b c e f g i n o
6020 // 3 a b d e f g j p q
6022 if ( matrix_s.getState( 0, 0 ) != X ) {
6025 if ( matrix_s.getState( 0, 1 ) != X ) {
6028 if ( matrix_s.getState( 0, 2 ) != X ) {
6031 if ( matrix_s.getState( 0, 3 ) != O ) {
6034 if ( matrix_s.getState( 0, 4 ) != X ) {
6037 if ( matrix_s.getState( 0, 5 ) != X ) {
6040 if ( matrix_s.getState( 0, 6 ) != X ) {
6043 if ( matrix_s.getState( 0, 7 ) != X ) {
6046 if ( matrix_s.getState( 0, 8 ) != O ) {
6049 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
6050 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
6051 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
6052 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list, map_same );
6053 dp0.executeDolloParsimonyOnSecondaryFeatures( null );
6054 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
6055 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
6056 if ( is_matrix_d.getState( "root", "AAA" ) != X ) {
6059 if ( is_matrix_d.getState( "root", "BBB" ) != X ) {
6062 if ( is_matrix_d.getState( "root", "CCC" ) != O ) {
6065 if ( is_matrix_d.getState( "root", "DDD" ) != O ) {
6068 if ( is_matrix_d.getState( "root", "EEE" ) != X ) {
6071 if ( gl_matrix_d.getState( "3-4", "PPP" ) != G ) {
6075 catch ( final Exception e ) {
6076 e.printStackTrace( System.out );
6082 private static boolean testPaupLogParser( final File test_dir ) {
6084 final PaupLogParser parser = new PaupLogParser();
6085 parser.setSource( new File( test_dir + ForesterUtil.getFileSeparator() + "paup_log_test_1" ) );
6086 final CharacterStateMatrix<BinaryStates> matrix = parser.parse();
6087 if ( matrix.getNumberOfIdentifiers() != 8 ) {
6090 if ( !matrix.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6093 if ( !matrix.getIdentifier( 1 ).equals( "NEMVE" ) ) {
6096 if ( !matrix.getIdentifier( 2 ).equals( "MONBE" ) ) {
6099 if ( !matrix.getIdentifier( 3 ).equals( "DICDI" ) ) {
6102 if ( !matrix.getIdentifier( 4 ).equals( "ARATH" ) ) {
6105 if ( !matrix.getIdentifier( 5 ).equals( "6" ) ) {
6108 if ( !matrix.getIdentifier( 6 ).equals( "7" ) ) {
6111 if ( !matrix.getIdentifier( 7 ).equals( "8" ) ) {
6114 if ( matrix.getNumberOfCharacters() != ( 66 + 66 + 28 ) ) {
6117 if ( matrix.getState( 0, 4 ) != BinaryStates.ABSENT ) {
6120 if ( matrix.getState( 0, 5 ) != BinaryStates.PRESENT ) {
6123 if ( matrix.getState( 1, 5 ) != BinaryStates.PRESENT ) {
6126 if ( matrix.getState( 7, 154 ) != BinaryStates.ABSENT ) {
6129 if ( matrix.getState( 7, 155 ) != BinaryStates.PRESENT ) {
6132 if ( matrix.getState( 7, 156 ) != BinaryStates.PRESENT ) {
6135 if ( matrix.getState( 7, 157 ) != BinaryStates.ABSENT ) {
6138 if ( matrix.getState( 7, 158 ) != BinaryStates.PRESENT ) {
6141 if ( matrix.getState( 7, 159 ) != BinaryStates.ABSENT ) {
6145 catch ( final Exception e ) {
6146 e.printStackTrace( System.out );
6152 private static boolean testProteinId() {
6154 final ProteinId id1 = new ProteinId( "a" );
6155 final ProteinId id2 = new ProteinId( "a" );
6156 final ProteinId id3 = new ProteinId( "A" );
6157 final ProteinId id4 = new ProteinId( "b" );
6158 if ( !id1.equals( id1 ) ) {
6161 if ( id1.getId().equals( "x" ) ) {
6164 if ( id1.getId().equals( null ) ) {
6167 if ( !id1.equals( id2 ) ) {
6170 if ( id1.equals( id3 ) ) {
6173 if ( id1.hashCode() != id1.hashCode() ) {
6176 if ( id1.hashCode() != id2.hashCode() ) {
6179 if ( id1.hashCode() == id3.hashCode() ) {
6182 if ( id1.compareTo( id1 ) != 0 ) {
6185 if ( id1.compareTo( id2 ) != 0 ) {
6188 if ( id1.compareTo( id3 ) != 0 ) {
6191 if ( id1.compareTo( id4 ) >= 0 ) {
6194 if ( id4.compareTo( id1 ) <= 0 ) {
6197 if ( !id4.getId().equals( "b" ) ) {
6200 final ProteinId id5 = new ProteinId( " C " );
6201 if ( !id5.getId().equals( "C" ) ) {
6204 if ( id5.equals( id1 ) ) {
6208 catch ( final Exception e ) {
6209 e.printStackTrace( System.out );
6215 private static boolean testSpecies() {
6217 final Species s1 = new BasicSpecies( "a" );
6218 final Species s2 = new BasicSpecies( "a" );
6219 final Species s3 = new BasicSpecies( "A" );
6220 final Species s4 = new BasicSpecies( "b" );
6221 if ( !s1.equals( s1 ) ) {
6224 if ( s1.getSpeciesId().equals( "x" ) ) {
6227 if ( s1.getSpeciesId().equals( null ) ) {
6230 if ( !s1.equals( s2 ) ) {
6233 if ( s1.equals( s3 ) ) {
6236 if ( s1.hashCode() != s1.hashCode() ) {
6239 if ( s1.hashCode() != s2.hashCode() ) {
6242 if ( s1.hashCode() == s3.hashCode() ) {
6245 if ( s1.compareTo( s1 ) != 0 ) {
6248 if ( s1.compareTo( s2 ) != 0 ) {
6251 if ( s1.compareTo( s3 ) != 0 ) {
6254 if ( s1.compareTo( s4 ) >= 0 ) {
6257 if ( s4.compareTo( s1 ) <= 0 ) {
6260 if ( !s4.getSpeciesId().equals( "b" ) ) {
6263 final Species s5 = new BasicSpecies( " C " );
6264 if ( !s5.getSpeciesId().equals( "C" ) ) {
6267 if ( s5.equals( s1 ) ) {
6271 catch ( final Exception e ) {
6272 e.printStackTrace( System.out );