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.protein.BasicDomain;
52 import org.forester.protein.BasicProtein;
53 import org.forester.protein.BinaryDomainCombination;
54 import org.forester.protein.BinaryDomainCombination.DomainCombinationType;
55 import org.forester.protein.Domain;
56 import org.forester.protein.DomainId;
57 import org.forester.protein.Protein;
58 import org.forester.protein.ProteinId;
59 import org.forester.species.BasicSpecies;
60 import org.forester.species.Species;
61 import org.forester.test.Test;
62 import org.forester.util.ForesterUtil;
64 @SuppressWarnings( "unused")
65 public class TestSurfacing {
67 private final static double ZERO_DIFF = 1.0E-9;
69 public static boolean isEqual( final double a, final double b ) {
70 return ( ( Math.abs( a - b ) ) < TestSurfacing.ZERO_DIFF );
73 private static StringBuffer mapToStringBuffer( final Map<PhylogenyNode, CharacterStateMatrix.BinaryStates> map ) {
74 final StringBuffer sb = new StringBuffer();
75 for( final PhylogenyNode key : map.keySet() ) {
76 if ( !key.isExternal() ) {
77 sb.append( key.getName() );
79 sb.append( map.get( key ).toString() );
80 sb.append( ForesterUtil.getLineSeparator() );
86 public static boolean test( final File test_dir ) {
87 System.out.print( " Domain id: " );
88 if ( !TestSurfacing.testDomainId() ) {
89 System.out.println( "failed." );
92 System.out.println( "OK." );
93 System.out.print( " Protein id: " );
94 if ( !TestSurfacing.testProteinId() ) {
95 System.out.println( "failed." );
98 System.out.println( "OK." );
99 System.out.print( " Species: " );
100 if ( !TestSurfacing.testSpecies() ) {
101 System.out.println( "failed." );
104 System.out.println( "OK." );
105 System.out.print( " Basic domain: " );
106 if ( !TestSurfacing.testBasicDomain() ) {
107 System.out.println( "failed." );
110 System.out.println( "OK." );
111 System.out.print( " Basic protein: " );
112 if ( !TestSurfacing.testBasicProtein() ) {
113 System.out.println( "failed." );
116 System.out.println( "OK." );
117 System.out.print( " Combinable domains: " );
118 if ( !TestSurfacing.testCombinableDomains() ) {
119 System.out.println( "failed." );
122 System.out.println( "OK." );
123 System.out.print( " Directed combinable domains: " );
124 if ( !TestSurfacing.testDirectedCombinableDomains() ) {
125 System.out.println( "failed." );
128 System.out.println( "OK." );
129 System.out.print( " Genome wide specific combinable domains: " );
130 if ( !TestSurfacing.testGenomeWideCombinableDomains() ) {
131 System.out.println( "failed." );
134 System.out.println( "OK." );
135 System.out.print( " Domain architecture based genome similarity calculator: " );
136 if ( !TestSurfacing.testDomainArchitectureBasedGenomeSimilarityCalculator() ) {
137 System.out.println( "failed." );
140 System.out.println( "OK." );
141 System.out.print( " Hmmpfam output parser: " );
142 if ( !TestSurfacing.testHmmPfamOutputParser( test_dir ) ) {
143 System.out.println( "failed." );
146 System.out.println( "OK." );
147 System.out.print( " Hmmpfam output parser with filter: " );
148 if ( !TestSurfacing.testHmmPfamOutputParserWithFilter( test_dir ) ) {
149 System.out.println( "failed." );
152 System.out.println( "OK." );
153 System.out.print( " Combinations based pairwise similarity calculator: " );
154 if ( !TestSurfacing.testCombinationsBasedPairwiseSimilarityCalculator() ) {
155 System.out.println( "failed." );
158 System.out.println( "OK." );
159 System.out.print( " Copy number based pairwise similarity calculator: " );
160 if ( !TestSurfacing.testCopyNumberBasedPairwiseSimilarityCalculator() ) {
163 System.out.println( "OK." );
164 System.out.print( " Domain combination counting: " );
165 if ( !TestSurfacing.testDomainCombinationCounting( test_dir ) ) {
166 System.out.println( "failed." );
169 System.out.println( "OK." );
170 System.out.print( " Basic domain similarity calculator: " );
171 if ( !TestSurfacing.testBasicDomainSimilarityCalculator() ) {
172 System.out.println( "failed." );
175 System.out.println( "OK." );
176 System.out.print( " Basic domain similarity calculator not ignoring species specific domains: " );
177 if ( !TestSurfacing.testBasicDomainSimilarityCalculatorNotIgnoringSpeciesSpeficDomains() ) {
178 System.out.println( "failed." );
181 System.out.println( "OK." );
182 System.out.print( " Basic domain similarity calculator removal of singles: " );
183 if ( !TestSurfacing.testBasicDomainSimilarityCalculatorRemovalOfSingles() ) {
184 System.out.println( "failed." );
187 System.out.println( "OK." );
188 System.out.print( " Domain sorting: " );
189 if ( !TestSurfacing.testDomainSorting() ) {
190 System.out.println( "failed." );
193 System.out.println( "OK." );
194 System.out.print( " Overlap removal: " );
195 if ( !TestSurfacing.testOverlapRemoval() ) {
196 System.out.println( "failed." );
199 System.out.println( "OK." );
200 System.out.print( " Engulfing overlap removal: " );
201 if ( !TestSurfacing.testEngulfingOverlapRemoval() ) {
202 System.out.println( "failed." );
205 System.out.println( "OK." );
206 System.out.print( " Binary domain combination: " );
207 if ( !TestSurfacing.testBinaryDomainCombination() ) {
208 System.out.println( "failed." );
211 System.out.println( "OK." );
212 System.out.print( " Parsimony: " );
213 if ( !TestSurfacing.testParsimony() ) {
214 System.out.println( "failed." );
217 System.out.println( "OK." );
218 System.out.print( " Directedness: " );
219 if ( !TestSurfacing.testDirectedness() ) {
220 System.out.println( "failed." );
223 System.out.println( "OK." );
224 System.out.print( " Directedness and adjacency: " );
225 if ( !TestSurfacing.testDirectednessAndAdjacency() ) {
226 System.out.println( "failed." );
229 System.out.println( "OK." );
230 System.out.print( " Dollo parsimony on secodary features: " );
231 if ( !TestSurfacing.testParsimonyOnSecondaryFeatures() ) {
232 System.out.println( "failed." );
235 System.out.println( "OK." );
236 System.out.print( " Paup log parser: " );
237 if ( !TestSurfacing.testPaupLogParser( test_dir ) ) {
238 System.out.println( "failed." );
241 System.out.println( "OK." );
242 System.out.print( " Binary state matrix to gain loss matrix: " );
243 if ( !TestSurfacing.testBinaryStateMatrixToGainLossMatrix( test_dir ) ) {
244 System.out.println( "failed." );
247 System.out.println( "OK." );
251 private static boolean testBasicDomain() {
253 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
254 if ( !pd.getDomainId().getId().equals( "id" ) ) {
257 if ( pd.getNumber() != 1 ) {
260 if ( pd.getTotalCount() != 4 ) {
263 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
266 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
267 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
268 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
269 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
270 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
271 if ( !a1.equals( a1 ) ) {
274 if ( !a1.equals( a1_copy ) ) {
277 if ( !a1.equals( a1_equal ) ) {
280 if ( !a1.equals( a2 ) ) {
283 if ( a1.equals( a3 ) ) {
286 if ( a1.compareTo( a1 ) != 0 ) {
289 if ( a1.compareTo( a1_copy ) != 0 ) {
292 if ( a1.compareTo( a1_equal ) != 0 ) {
295 if ( a1.compareTo( a2 ) != 0 ) {
298 if ( a1.compareTo( a3 ) != 0 ) {
302 catch ( final Exception e ) {
303 e.printStackTrace( System.out );
309 private static boolean testBasicDomainSimilarityCalculator() {
317 // m 2/(2+3) 0 4/(4+2)
322 // mean = ( 2/5 + 0 + 2/3 + 1/5 + 1/2 + 2/7 ) / 6
342 // m - 2/(2+3) 4/(4+2)
346 // mean = (2/5 + 2/3 + 1/2)/3 =
352 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
353 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
354 final Domain C = new BasicDomain( "C", 1, 2, ( short ) 1, ( short ) 1, 0.3, -12 );
355 final Domain D = new BasicDomain( "D", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
356 final Domain E = new BasicDomain( "E", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
357 final Domain F = new BasicDomain( "F", 1, 2, ( short ) 1, ( short ) 1, 0.01, -12 );
358 final Domain G = new BasicDomain( "G", 1, 2, ( short ) 1, ( short ) 1, 0.001, -12 );
359 final Domain X = new BasicDomain( "X", 1, 2, ( short ) 1, ( short ) 1, 0.0001, -12 );
360 if ( !TestSurfacing.isEqual( X.getPerSequenceScore(), -12 ) ) {
363 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
364 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
365 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
366 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
367 mouse_1.addProteinDomain( A );
368 mouse_1.addProteinDomain( B );
369 mouse_1.addProteinDomain( C );
370 mouse_1.addProteinDomain( D );
371 mouse_1.addProteinDomain( E );
372 rabbit_1.addProteinDomain( A );
373 rabbit_1.addProteinDomain( C );
374 rabbit_1.addProteinDomain( E );
375 rabbit_1.addProteinDomain( F );
376 rabbit_1.addProteinDomain( F );
377 rabbit_1.addProteinDomain( F );
378 rabbit_1.addProteinDomain( F );
379 rabbit_1.addProteinDomain( F );
380 rabbit_1.addProteinDomain( F );
381 ciona_1.addProteinDomain( A );
382 ciona_1.addProteinDomain( A );
383 ciona_1.addProteinDomain( A );
384 ciona_1.addProteinDomain( A );
385 ciona_1.addProteinDomain( A );
386 ciona_1.addProteinDomain( F );
387 ciona_1.addProteinDomain( G );
388 ciona_1.addProteinDomain( X );
389 nemve_1.addProteinDomain( A );
390 nemve_1.addProteinDomain( B );
391 nemve_1.addProteinDomain( C );
392 nemve_1.addProteinDomain( D );
393 nemve_1.addProteinDomain( E );
394 nemve_1.addProteinDomain( F );
395 nemve_1.addProteinDomain( G );
396 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
397 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
398 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
399 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
400 protein_list_mouse.add( mouse_1 );
401 protein_list_rabbit.add( rabbit_1 );
402 protein_list_ciona.add( ciona_1 );
403 protein_list_nemve.add( nemve_1 );
404 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
405 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
407 new BasicSpecies( "mouse" ) ) );
408 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
410 new BasicSpecies( "rabbit" ) ) );
411 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
413 new BasicSpecies( "ciona" ) ) );
414 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
416 new BasicSpecies( "nemve" ) ) );
417 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
420 final SortedSet<DomainSimilarity> sims = calc
421 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
425 final Iterator<DomainSimilarity> sims_it = sims.iterator();
426 final DomainSimilarity sa = sims_it.next();
427 if ( !sa.getDomainId().getId().equals( "A" ) ) {
430 if ( sa.getSpeciesData().size() != 4 ) {
433 if ( !sa.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
436 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
439 if ( !sa.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
442 if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
445 if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + 0 + ( 2.0 / 3 ) + ( 1.0 / 5 )
446 + ( 1.0 / 2 ) + ( 2.0 / 7 ) ) / 6 ) ) {
449 if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), ( 0.23410788192183737 ) ) ) {
452 if ( !TestSurfacing.isEqual( sa.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
455 if ( !TestSurfacing.isEqual( sa.getMinimalSimilarityScore(), ( 0.0 ) ) ) {
458 if ( sa.getN() != 6 ) {
461 if ( sa.getMaximalDifference() != 7 ) {
464 if ( sa.getMaximalDifferenceInCounts() != 3 ) {
467 final DomainSimilarity sb = sims_it.next();
468 if ( !sb.getDomainId().getId().equals( "B" ) ) {
471 if ( sb.getSpeciesData().size() != 2 ) {
474 if ( !sb.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
477 if ( !sb.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
480 if ( !TestSurfacing.isEqual( sb.getMeanSimilarityScore(), 2.0 / 3 ) ) {
483 if ( !TestSurfacing.isEqual( sb.getStandardDeviationOfSimilarityScore(), 0.0 ) ) {
486 if ( !TestSurfacing.isEqual( sb.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
489 if ( !TestSurfacing.isEqual( sb.getMinimalSimilarityScore(), ( 2.0 / 3 ) ) ) {
492 if ( sb.getN() != 1 ) {
495 if ( sb.getMaximalDifference() != 2 ) {
498 if ( sb.getMaximalDifferenceInCounts() != 2 ) {
501 final DomainSimilarity sc = sims_it.next();
502 if ( !sc.getDomainId().getId().equals( "C" ) ) {
505 if ( sc.getSpeciesData().size() != 3 ) {
508 if ( !sc.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
511 if ( !sc.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
514 if ( !sc.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
517 if ( !TestSurfacing.isEqual( sc.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + ( 2.0 / 3 ) + ( 1.0 / 2 ) ) / 3 ) ) {
520 if ( !TestSurfacing.isEqual( sc.getStandardDeviationOfSimilarityScore(), 0.13471506281091264 ) ) {
523 if ( !TestSurfacing.isEqual( sc.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
526 if ( !TestSurfacing.isEqual( sc.getMinimalSimilarityScore(), ( 2.0 / 5 ) ) ) {
529 if ( sc.getN() != 3 ) {
532 if ( sc.getMaximalDifference() != 3 ) {
535 if ( sc.getMaximalDifferenceInCounts() != 3 ) {
538 // mouse : ....ABCDE.....
539 // rabbit: ....A.C.EFFF..
540 // ciona : AAAAA......FGX
541 // nemve : ....ABCDEFG...
545 // m 2/(2+3) 0 4/(4+2)
546 // r - 1/(1+5) 3/(3+3)
550 // mean = ( 2/5 + 0 + 2/3 + 1/6 + 1/2 + 2/8 ) / 6
554 final List<GenomeWideCombinableDomains> cdc_list2 = new ArrayList<GenomeWideCombinableDomains>();
555 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
557 new BasicSpecies( "mouse" ) ) );
558 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
560 new BasicSpecies( "rabbit" ) ) );
561 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
563 new BasicSpecies( "ciona" ) ) );
564 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
566 new BasicSpecies( "nemve" ) ) );
567 final DomainSimilarityCalculator calc2 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
570 final SortedSet<DomainSimilarity> sims2 = calc2
571 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
575 final Iterator<DomainSimilarity> sims_it2 = sims2.iterator();
576 final DomainSimilarity sa2 = sims_it2.next();
577 if ( !sa2.getDomainId().getId().equals( "A" ) ) {
580 if ( sa2.getSpeciesData().size() != 4 ) {
583 if ( !sa2.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
586 if ( !sa2.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
589 if ( !sa2.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
592 if ( !sa2.getSpeciesData().keySet().contains( new BasicSpecies( "rabbit" ) ) ) {
595 if ( !TestSurfacing.isEqual( sa2.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + 0 + ( 2.0 / 3 ) + ( 1.0 / 6 )
596 + ( 1.0 / 2 ) + ( 2.0 / 8 ) ) / 6 ) ) {
599 if ( !TestSurfacing.isEqual( sa2.getStandardDeviationOfSimilarityScore(), ( 0.2404663678647683 ) ) ) {
602 if ( !TestSurfacing.isEqual( sa2.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
605 if ( !TestSurfacing.isEqual( sa2.getMinimalSimilarityScore(), ( 0.0 ) ) ) {
608 if ( sa2.getN() != 6 ) {
611 if ( sa2.getMaximalDifference() != 8 ) {
614 if ( sa2.getMaximalDifferenceInCounts() != 3 ) {
617 final Protein ciona_2 = new BasicProtein( "2", "ciona", 0 );
618 ciona_2.addProteinDomain( A );
619 ciona_2.addProteinDomain( A );
620 ciona_2.addProteinDomain( A );
621 ciona_2.addProteinDomain( B );
622 ciona_2.addProteinDomain( B );
623 ciona_2.addProteinDomain( B );
624 ciona_2.addProteinDomain( F );
625 ciona_2.addProteinDomain( F );
626 ciona_2.addProteinDomain( F );
627 ciona_2.addProteinDomain( F );
628 ciona_2.addProteinDomain( G );
629 ciona_2.addProteinDomain( X );
630 final Protein ciona_3 = new BasicProtein( "3", "ciona", 0 );
631 ciona_3.addProteinDomain( A );
632 ciona_3.addProteinDomain( A );
633 ciona_3.addProteinDomain( A );
634 ciona_3.addProteinDomain( A );
635 ciona_3.addProteinDomain( B );
636 ciona_3.addProteinDomain( B );
637 ciona_3.addProteinDomain( X );
638 ciona_3.addProteinDomain( X );
639 protein_list_ciona.add( ciona_2 );
640 protein_list_ciona.add( ciona_3 );
641 final List<GenomeWideCombinableDomains> cdc_list3 = new ArrayList<GenomeWideCombinableDomains>();
642 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
644 new BasicSpecies( "mouse" ) ) );
645 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
647 new BasicSpecies( "rabbit" ) ) );
648 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
650 new BasicSpecies( "ciona" ) ) );
651 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
653 new BasicSpecies( "nemve" ) ) );
654 final DomainSimilarityCalculator calc3 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
657 final SortedSet<DomainSimilarity> sims3 = calc3
658 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
662 final Iterator<DomainSimilarity> sims_it3 = sims3.iterator();
663 final DomainSimilarity sa3 = sims_it3.next();
664 if ( !sa3.getDomainId().getId().equals( "A" ) ) {
667 final SpeciesSpecificDomainSimilariyData ssdsd = sa3.getSpeciesData().get( new BasicSpecies( "ciona" ) );
668 if ( ssdsd.getCombinableDomainIdToCountsMap().size() != 4 ) {
671 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
674 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
677 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
680 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
683 final List<GenomeWideCombinableDomains> cdc_list4 = new ArrayList<GenomeWideCombinableDomains>();
684 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
686 new BasicSpecies( "mouse" ) ) );
687 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
689 new BasicSpecies( "rabbit" ) ) );
690 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
692 new BasicSpecies( "ciona" ) ) );
694 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
696 new BasicSpecies( "nemve" ) ) );
697 final DomainSimilarityCalculator calc4 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
700 final SortedSet<DomainSimilarity> sims4 = calc4
701 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
705 final Iterator<DomainSimilarity> sims_it4 = sims4.iterator();
706 final DomainSimilarity sa4 = sims_it4.next();
707 if ( !sa4.getDomainId().getId().equals( "A" ) ) {
710 final SpeciesSpecificDomainSimilariyData ssdsd4 = sa4.getSpeciesData().get( new BasicSpecies( "ciona" ) );
711 if ( ssdsd4.getCombinableDomainIdToCountsMap().size() != 5 ) {
714 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "A" ) ) != 3 ) {
717 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
720 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
723 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
726 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
729 final SortedSet<DomainSimilarity> sims4_d = calc4
730 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list4, false, true );
731 final Iterator<DomainSimilarity> sims_it4_d = sims4_d.iterator();
732 final DomainSimilarity sa4_d = sims_it4_d.next();
733 if ( !sa4_d.getDomainId().getId().equals( "A" ) ) {
736 if ( sa4_d.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
740 .isEqual( sa4_d.getMeanSimilarityScore(),
741 ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
744 if ( !TestSurfacing.isEqual( sa4_d.getMaximalSimilarityScore(), 1.0 ) ) {
747 if ( !TestSurfacing.isEqual( sa4_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
750 if ( sa4_d.getN() != 6 ) {
753 final SortedSet<DomainSimilarity> sims4_p = calc4
754 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
758 final Iterator<DomainSimilarity> sims_it4_p = sims4_p.iterator();
759 final DomainSimilarity sa4_p = sims_it4_p.next();
760 if ( !sa4_p.getDomainId().getId().equals( "A" ) ) {
763 if ( sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
766 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "A" ) ) ) {
769 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "B" ) ) ) {
772 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "F" ) ) ) {
775 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "G" ) ) ) {
778 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "X" ) ) ) {
782 .isEqual( sa4_p.getMeanSimilarityScore(),
783 ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
786 if ( !TestSurfacing.isEqual( sa4_p.getMaximalSimilarityScore(), 1 ) ) {
789 if ( !TestSurfacing.isEqual( sa4_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
792 if ( sa4_p.getN() != 6 ) {
795 final List<GenomeWideCombinableDomains> cdc_list5 = new ArrayList<GenomeWideCombinableDomains>();
796 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
798 new BasicSpecies( "mouse" ) ) );
799 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
801 new BasicSpecies( "rabbit" ) ) );
802 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
804 new BasicSpecies( "ciona" ) ) );
805 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
807 new BasicSpecies( "nemve" ) ) );
808 final SortedSet<DomainSimilarity> sims5_d = calc4
809 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list5, false, true );
810 final Iterator<DomainSimilarity> sims_it5_d = sims5_d.iterator();
811 final DomainSimilarity sa5_d = sims_it5_d.next();
812 if ( sa5_d.getSpecies().size() != 4 ) {
815 if ( !sa5_d.getSpecies().last().equals( new BasicSpecies( "rabbit" ) ) ) {
818 final SpeciesSpecificDomainSimilariyData ssdsd5 = sa5_d.getSpeciesData().get( new BasicSpecies( "ciona" ) );
819 if ( ssdsd5.getCombinableDomainIdToCountsMap().size() != 4 ) {
822 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
825 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
828 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
831 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
834 if ( !sa5_d.getDomainId().getId().equals( "A" ) ) {
837 final Species ciona = new BasicSpecies( "ciona" );
838 if ( sa5_d.getCombinableDomainIds( ciona ).size() != 4 ) {
841 if ( sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
844 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
847 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
850 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
853 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
857 .isEqual( sa5_d.getMeanSimilarityScore(),
858 ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
861 if ( !TestSurfacing.isEqual( sa5_d.getMaximalSimilarityScore(), 1.0 ) ) {
864 if ( !TestSurfacing.isEqual( sa5_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
867 if ( sa5_d.getN() != 6 ) {
870 if ( sa5_d.getMaximalDifference() != sa5_d.getMaximalDifferenceInCounts() ) {
873 if ( sa5_d.getMaximalDifference() != 11 ) {
876 if ( sa5_d.getMaximalDifferenceInCounts() != 11 ) {
879 final SortedSet<DomainSimilarity> sims5_p = calc4
880 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
884 final Iterator<DomainSimilarity> sims_it5_p = sims5_p.iterator();
885 final DomainSimilarity sa5_p = sims_it5_p.next();
886 if ( !sa5_p.getDomainId().getId().equals( "A" ) ) {
889 if ( sa5_p.getCombinableDomainIds( ciona ).size() != 4 ) {
892 if ( sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
895 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
898 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
901 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
904 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
908 .isEqual( sa5_p.getMeanSimilarityScore(),
909 ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
912 if ( !TestSurfacing.isEqual( sa5_p.getMaximalSimilarityScore(), 1 ) ) {
915 if ( !TestSurfacing.isEqual( sa5_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
918 if ( sa5_p.getN() != 6 ) {
921 if ( sa5_p.getMaximalDifference() != sa5_p.getMaximalDifferenceInCounts() ) {
924 if ( sa5_p.getMaximalDifference() != 2 ) {
927 if ( sa5_p.getMaximalDifferenceInCounts() != 2 ) {
930 final List<GenomeWideCombinableDomains> cdc_list6 = new ArrayList<GenomeWideCombinableDomains>();
931 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
933 new BasicSpecies( "mouse" ) ) );
934 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
936 new BasicSpecies( "rabbit" ) ) );
937 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
939 new BasicSpecies( "ciona" ) ) );
940 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
942 new BasicSpecies( "nemve" ) ) );
943 final SortedSet<DomainSimilarity> sims6_d = calc4
944 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list6, false, true );
945 final Iterator<DomainSimilarity> sims_it6_d = sims6_d.iterator();
946 final DomainSimilarity sa6_d = sims_it6_d.next();
947 if ( sa6_d.getSpecies().size() != 4 ) {
950 if ( !sa6_d.getSpecies().last().equals( new BasicSpecies( "rabbit" ) ) ) {
953 final SpeciesSpecificDomainSimilariyData ssdsd6 = sa6_d.getSpeciesData().get( new BasicSpecies( "ciona" ) );
954 if ( ssdsd6.getCombinableDomainIdToCountsMap().size() != 5 ) {
957 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
960 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
963 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
966 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
969 if ( !sa5_d.getDomainId().getId().equals( "A" ) ) {
972 final Species ciona6 = new BasicSpecies( "ciona" );
973 if ( sa6_d.getCombinableDomainIds( ciona6 ).size() != 5 ) {
976 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "A" ) ) ) {
979 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "B" ) ) ) {
982 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "F" ) ) ) {
985 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "G" ) ) ) {
988 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "X" ) ) ) {
992 .isEqual( sa6_d.getMeanSimilarityScore(),
993 ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
996 if ( !TestSurfacing.isEqual( sa6_d.getMaximalSimilarityScore(), 1.0 ) ) {
999 if ( !TestSurfacing.isEqual( sa6_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
1002 if ( sa6_d.getN() != 6 ) {
1005 if ( sa6_d.getMaximalDifference() != sa6_d.getMaximalDifferenceInCounts() ) {
1008 if ( sa6_d.getMaximalDifference() != 11 ) {
1011 if ( sa6_d.getMaximalDifferenceInCounts() != 11 ) {
1014 final SortedSet<DomainSimilarity> sims6_p = calc4
1015 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
1019 final Iterator<DomainSimilarity> sims_it6_p = sims6_p.iterator();
1020 final DomainSimilarity sa6_p = sims_it6_p.next();
1021 if ( !sa6_p.getDomainId().getId().equals( "A" ) ) {
1024 if ( sa6_p.getCombinableDomainIds( ciona ).size() != 5 ) {
1027 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
1030 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
1033 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
1036 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
1039 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
1043 .isEqual( sa6_p.getMeanSimilarityScore(),
1044 ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
1047 if ( !TestSurfacing.isEqual( sa6_p.getMaximalSimilarityScore(), 1 ) ) {
1050 if ( !TestSurfacing.isEqual( sa6_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
1053 if ( sa6_p.getN() != 6 ) {
1056 if ( sa6_p.getMaximalDifference() != sa6_p.getMaximalDifferenceInCounts() ) {
1059 if ( sa6_p.getMaximalDifference() != 2 ) {
1062 if ( sa6_p.getMaximalDifferenceInCounts() != 2 ) {
1066 catch ( final Exception e ) {
1067 e.printStackTrace( System.out );
1073 private static boolean testBasicDomainSimilarityCalculatorNotIgnoringSpeciesSpeficDomains() {
1075 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
1076 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
1077 final Domain D = new BasicDomain( "D", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
1078 final Domain E = new BasicDomain( "E", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
1079 final Domain F = new BasicDomain( "F", 1, 2, ( short ) 1, ( short ) 1, 0.01, -12 );
1080 final Domain G = new BasicDomain( "G", 1, 2, ( short ) 1, ( short ) 1, 0.001, -12 );
1081 final Domain X = new BasicDomain( "X", 1, 2, ( short ) 1, ( short ) 1, 0.0001, -12 );
1082 if ( !TestSurfacing.isEqual( X.getPerSequenceScore(), -12 ) ) {
1085 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
1086 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
1087 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
1088 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
1089 mouse_1.addProteinDomain( A );
1090 mouse_1.addProteinDomain( D );
1091 mouse_1.addProteinDomain( E );
1092 rabbit_1.addProteinDomain( B );
1093 rabbit_1.addProteinDomain( E );
1094 rabbit_1.addProteinDomain( F );
1095 rabbit_1.addProteinDomain( F );
1096 rabbit_1.addProteinDomain( F );
1097 rabbit_1.addProteinDomain( F );
1098 rabbit_1.addProteinDomain( F );
1099 rabbit_1.addProteinDomain( F );
1100 ciona_1.addProteinDomain( F );
1101 ciona_1.addProteinDomain( G );
1102 ciona_1.addProteinDomain( X );
1103 nemve_1.addProteinDomain( D );
1104 nemve_1.addProteinDomain( E );
1105 nemve_1.addProteinDomain( F );
1106 nemve_1.addProteinDomain( G );
1107 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
1108 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
1109 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
1110 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
1111 protein_list_mouse.add( mouse_1 );
1112 protein_list_rabbit.add( rabbit_1 );
1113 protein_list_ciona.add( ciona_1 );
1114 protein_list_nemve.add( nemve_1 );
1115 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
1116 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
1118 new BasicSpecies( "mouse" ) ) );
1119 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
1121 new BasicSpecies( "rabbit" ) ) );
1122 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
1124 new BasicSpecies( "ciona" ) ) );
1125 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
1127 new BasicSpecies( "nemve" ) ) );
1128 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
1131 final SortedSet<DomainSimilarity> sims = calc
1132 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1136 final Iterator<DomainSimilarity> sims_it = sims.iterator();
1137 final DomainSimilarity sa = sims_it.next();
1138 if ( !sa.getDomainId().getId().equals( "A" ) ) {
1141 if ( sa.getSpeciesData().size() != 1 ) {
1144 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
1147 if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(), 1.0 ) ) {
1150 if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), 0.0 ) ) {
1153 if ( !TestSurfacing.isEqual( sa.getMaximalSimilarityScore(), 1.0 ) ) {
1156 if ( !TestSurfacing.isEqual( sa.getMinimalSimilarityScore(), 1.0 ) ) {
1159 if ( sa.getN() != 0 ) {
1162 if ( sa.getMaximalDifference() != 0 ) {
1165 if ( sa.getMaximalDifferenceInCounts() != 0 ) {
1168 final DomainSimilarity sb = sims_it.next();
1169 if ( !sb.getDomainId().getId().equals( "B" ) ) {
1172 if ( sb.getSpeciesData().size() != 1 ) {
1175 if ( !sb.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
1178 final SortedSet<DomainSimilarity> sims2 = calc
1179 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1183 final Iterator<DomainSimilarity> sims_it2 = sims2.iterator();
1184 final DomainSimilarity sa2 = sims_it2.next();
1185 if ( !sa2.getDomainId().getId().equals( "D" ) ) {
1188 if ( sa2.getSpeciesData().size() != 2 ) {
1192 catch ( final Exception e ) {
1193 e.printStackTrace( System.out );
1199 private static boolean testBasicDomainSimilarityCalculatorRemovalOfSingles() {
1201 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
1202 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
1203 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
1204 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
1205 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
1206 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
1207 mouse_1.addProteinDomain( A );
1208 rabbit_1.addProteinDomain( A );
1209 ciona_1.addProteinDomain( A );
1210 ciona_1.addProteinDomain( A );
1211 ciona_1.addProteinDomain( A );
1212 ciona_1.addProteinDomain( A );
1213 ciona_1.addProteinDomain( A );
1214 nemve_1.addProteinDomain( A );
1215 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
1216 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
1217 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
1218 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
1219 protein_list_mouse.add( mouse_1 );
1220 protein_list_rabbit.add( rabbit_1 );
1221 protein_list_ciona.add( ciona_1 );
1222 protein_list_nemve.add( nemve_1 );
1223 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
1224 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
1226 new BasicSpecies( "mouse" ) ) );
1227 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
1229 new BasicSpecies( "rabbit" ) ) );
1230 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
1232 new BasicSpecies( "ciona" ) ) );
1233 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
1235 new BasicSpecies( "nemve" ) ) );
1236 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
1239 final SortedSet<DomainSimilarity> sims = calc
1240 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1244 if ( sims.size() != 1 ) {
1247 final Iterator<DomainSimilarity> sims_it = sims.iterator();
1248 final DomainSimilarity sa = sims_it.next();
1249 if ( !sa.getDomainId().getId().equals( "A" ) ) {
1252 if ( sa.getSpeciesData().size() != 4 ) {
1255 if ( !sa.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
1258 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
1261 if ( !sa.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
1264 if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
1267 final SortedSet<DomainSimilarity> sims_ns = calc
1268 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1272 if ( sims_ns.size() != 0 ) {
1275 final Protein mouse_2 = new BasicProtein( "1", "mouse", 0 );
1276 final Protein rabbit_2 = new BasicProtein( "1", "rabbit", 0 );
1277 final Protein ciona_2 = new BasicProtein( "1", "ciona", 0 );
1278 final Protein nemve_2 = new BasicProtein( "1", "nemve", 0 );
1279 mouse_2.addProteinDomain( A );
1280 rabbit_2.addProteinDomain( A );
1281 ciona_2.addProteinDomain( A );
1282 ciona_2.addProteinDomain( A );
1283 ciona_2.addProteinDomain( B );
1284 ciona_2.addProteinDomain( A );
1285 ciona_2.addProteinDomain( A );
1286 ciona_2.addProteinDomain( A );
1287 nemve_2.addProteinDomain( A );
1288 final List<Protein> protein_list_mouse2 = new ArrayList<Protein>();
1289 final List<Protein> protein_list_rabbit2 = new ArrayList<Protein>();
1290 final List<Protein> protein_list_ciona2 = new ArrayList<Protein>();
1291 final List<Protein> protein_list_nemve2 = new ArrayList<Protein>();
1292 protein_list_mouse2.add( mouse_2 );
1293 protein_list_rabbit2.add( rabbit_2 );
1294 protein_list_ciona2.add( ciona_2 );
1295 protein_list_nemve2.add( nemve_2 );
1296 final List<GenomeWideCombinableDomains> cdc_list2 = new ArrayList<GenomeWideCombinableDomains>();
1297 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse2,
1299 new BasicSpecies( "mouse" ) ) );
1300 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit2,
1302 new BasicSpecies( "rabbit" ) ) );
1303 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona2,
1305 new BasicSpecies( "ciona" ) ) );
1306 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve2,
1308 new BasicSpecies( "nemve" ) ) );
1309 final SortedSet<DomainSimilarity> sims2 = calc
1310 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1314 if ( sims2.size() != 1 ) {
1318 catch ( final Exception e ) {
1319 e.printStackTrace( System.out );
1325 private static boolean testBasicProtein() {
1327 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1328 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1329 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1330 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1331 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1332 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1333 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1334 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1335 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1336 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1337 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1338 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1339 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1340 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
1341 p.addProteinDomain( B15 );
1342 p.addProteinDomain( C50 );
1343 p.addProteinDomain( A60 );
1344 p.addProteinDomain( A30 );
1345 p.addProteinDomain( C70 );
1346 p.addProteinDomain( B35 );
1347 p.addProteinDomain( B40 );
1348 p.addProteinDomain( A0 );
1349 p.addProteinDomain( A10 );
1350 p.addProteinDomain( A20 );
1351 p.addProteinDomain( B25 );
1352 p.addProteinDomain( D80 );
1353 List<DomainId> domains_ids = new ArrayList<DomainId>();
1354 domains_ids.add( new DomainId( "A" ) );
1355 domains_ids.add( new DomainId( "B" ) );
1356 domains_ids.add( new DomainId( "C" ) );
1357 if ( !p.contains( domains_ids, false ) ) {
1360 if ( !p.contains( domains_ids, true ) ) {
1363 domains_ids.add( new DomainId( "X" ) );
1364 if ( p.contains( domains_ids, false ) ) {
1367 if ( p.contains( domains_ids, true ) ) {
1370 domains_ids = new ArrayList<DomainId>();
1371 domains_ids.add( new DomainId( "A" ) );
1372 domains_ids.add( new DomainId( "C" ) );
1373 domains_ids.add( new DomainId( "D" ) );
1374 if ( !p.contains( domains_ids, false ) ) {
1377 if ( !p.contains( domains_ids, true ) ) {
1380 domains_ids = new ArrayList<DomainId>();
1381 domains_ids.add( new DomainId( "A" ) );
1382 domains_ids.add( new DomainId( "D" ) );
1383 domains_ids.add( new DomainId( "C" ) );
1384 if ( !p.contains( domains_ids, false ) ) {
1387 if ( p.contains( domains_ids, true ) ) {
1390 domains_ids = new ArrayList<DomainId>();
1391 domains_ids.add( new DomainId( "A" ) );
1392 domains_ids.add( new DomainId( "A" ) );
1393 domains_ids.add( new DomainId( "B" ) );
1394 if ( !p.contains( domains_ids, false ) ) {
1397 if ( !p.contains( domains_ids, true ) ) {
1400 domains_ids = new ArrayList<DomainId>();
1401 domains_ids.add( new DomainId( "A" ) );
1402 domains_ids.add( new DomainId( "A" ) );
1403 domains_ids.add( new DomainId( "A" ) );
1404 domains_ids.add( new DomainId( "B" ) );
1405 domains_ids.add( new DomainId( "B" ) );
1406 if ( !p.contains( domains_ids, false ) ) {
1409 if ( !p.contains( domains_ids, true ) ) {
1412 domains_ids = new ArrayList<DomainId>();
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( "A" ) );
1417 domains_ids.add( new DomainId( "B" ) );
1418 domains_ids.add( new DomainId( "B" ) );
1419 if ( !p.contains( domains_ids, false ) ) {
1422 if ( !p.contains( domains_ids, true ) ) {
1425 domains_ids = new ArrayList<DomainId>();
1426 domains_ids.add( new DomainId( "A" ) );
1427 domains_ids.add( new DomainId( "A" ) );
1428 domains_ids.add( new DomainId( "A" ) );
1429 domains_ids.add( new DomainId( "A" ) );
1430 domains_ids.add( new DomainId( "A" ) );
1431 domains_ids.add( new DomainId( "B" ) );
1432 domains_ids.add( new DomainId( "B" ) );
1433 if ( !p.contains( domains_ids, false ) ) {
1436 if ( p.contains( domains_ids, true ) ) {
1439 domains_ids = new ArrayList<DomainId>();
1440 domains_ids.add( new DomainId( "A" ) );
1441 domains_ids.add( new DomainId( "A" ) );
1442 domains_ids.add( new DomainId( "B" ) );
1443 domains_ids.add( new DomainId( "A" ) );
1444 domains_ids.add( new DomainId( "B" ) );
1445 domains_ids.add( new DomainId( "A" ) );
1446 domains_ids.add( new DomainId( "B" ) );
1447 domains_ids.add( new DomainId( "B" ) );
1448 domains_ids.add( new DomainId( "C" ) );
1449 domains_ids.add( new DomainId( "A" ) );
1450 domains_ids.add( new DomainId( "C" ) );
1451 domains_ids.add( new DomainId( "D" ) );
1452 if ( !p.contains( domains_ids, false ) ) {
1455 if ( !p.contains( domains_ids, true ) ) {
1458 domains_ids = new ArrayList<DomainId>();
1459 domains_ids.add( new DomainId( "A" ) );
1460 domains_ids.add( new DomainId( "B" ) );
1461 domains_ids.add( new DomainId( "A" ) );
1462 domains_ids.add( new DomainId( "B" ) );
1463 domains_ids.add( new DomainId( "A" ) );
1464 domains_ids.add( new DomainId( "B" ) );
1465 domains_ids.add( new DomainId( "B" ) );
1466 domains_ids.add( new DomainId( "A" ) );
1467 domains_ids.add( new DomainId( "C" ) );
1468 domains_ids.add( new DomainId( "D" ) );
1469 if ( !p.contains( domains_ids, false ) ) {
1472 if ( !p.contains( domains_ids, true ) ) {
1475 domains_ids = new ArrayList<DomainId>();
1476 domains_ids.add( new DomainId( "A" ) );
1477 domains_ids.add( new DomainId( "A" ) );
1478 domains_ids.add( new DomainId( "B" ) );
1479 domains_ids.add( new DomainId( "A" ) );
1480 domains_ids.add( new DomainId( "B" ) );
1481 domains_ids.add( new DomainId( "A" ) );
1482 domains_ids.add( new DomainId( "B" ) );
1483 domains_ids.add( new DomainId( "B" ) );
1484 domains_ids.add( new DomainId( "C" ) );
1485 domains_ids.add( new DomainId( "C" ) );
1486 domains_ids.add( new DomainId( "A" ) );
1487 domains_ids.add( new DomainId( "C" ) );
1488 domains_ids.add( new DomainId( "D" ) );
1489 if ( !p.contains( domains_ids, false ) ) {
1492 if ( p.contains( domains_ids, true ) ) {
1495 domains_ids = new ArrayList<DomainId>();
1496 domains_ids.add( new DomainId( "A" ) );
1497 domains_ids.add( new DomainId( "A" ) );
1498 domains_ids.add( new DomainId( "A" ) );
1499 domains_ids.add( new DomainId( "B" ) );
1500 domains_ids.add( new DomainId( "A" ) );
1501 domains_ids.add( new DomainId( "B" ) );
1502 domains_ids.add( new DomainId( "A" ) );
1503 domains_ids.add( new DomainId( "B" ) );
1504 domains_ids.add( new DomainId( "B" ) );
1505 domains_ids.add( new DomainId( "C" ) );
1506 domains_ids.add( new DomainId( "A" ) );
1507 domains_ids.add( new DomainId( "C" ) );
1508 domains_ids.add( new DomainId( "D" ) );
1509 if ( !p.contains( domains_ids, false ) ) {
1512 if ( p.contains( domains_ids, true ) ) {
1515 domains_ids = new ArrayList<DomainId>();
1516 domains_ids.add( new DomainId( "A" ) );
1517 domains_ids.add( new DomainId( "A" ) );
1518 domains_ids.add( new DomainId( "B" ) );
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( "B" ) );
1524 domains_ids.add( new DomainId( "A" ) );
1525 domains_ids.add( new DomainId( "D" ) );
1526 if ( !p.contains( domains_ids, false ) ) {
1529 if ( !p.contains( domains_ids, true ) ) {
1532 domains_ids = new ArrayList<DomainId>();
1533 domains_ids.add( new DomainId( "A" ) );
1534 domains_ids.add( new DomainId( "A" ) );
1535 domains_ids.add( new DomainId( "B" ) );
1536 domains_ids.add( new DomainId( "A" ) );
1537 domains_ids.add( new DomainId( "B" ) );
1538 domains_ids.add( new DomainId( "A" ) );
1539 domains_ids.add( new DomainId( "B" ) );
1540 domains_ids.add( new DomainId( "B" ) );
1541 domains_ids.add( new DomainId( "C" ) );
1542 domains_ids.add( new DomainId( "A" ) );
1543 domains_ids.add( new DomainId( "C" ) );
1544 domains_ids.add( new DomainId( "D" ) );
1545 domains_ids.add( new DomainId( "X" ) );
1546 if ( p.contains( domains_ids, false ) ) {
1549 if ( p.contains( domains_ids, true ) ) {
1552 domains_ids = new ArrayList<DomainId>();
1553 domains_ids.add( new DomainId( "X" ) );
1554 domains_ids.add( new DomainId( "A" ) );
1555 domains_ids.add( new DomainId( "A" ) );
1556 domains_ids.add( new DomainId( "B" ) );
1557 domains_ids.add( new DomainId( "A" ) );
1558 domains_ids.add( new DomainId( "B" ) );
1559 domains_ids.add( new DomainId( "A" ) );
1560 domains_ids.add( new DomainId( "B" ) );
1561 domains_ids.add( new DomainId( "B" ) );
1562 domains_ids.add( new DomainId( "C" ) );
1563 domains_ids.add( new DomainId( "A" ) );
1564 domains_ids.add( new DomainId( "C" ) );
1565 domains_ids.add( new DomainId( "D" ) );
1566 if ( p.contains( domains_ids, false ) ) {
1569 if ( p.contains( domains_ids, true ) ) {
1572 domains_ids = new ArrayList<DomainId>();
1573 domains_ids.add( new DomainId( "A" ) );
1574 domains_ids.add( new DomainId( "A" ) );
1575 domains_ids.add( new DomainId( "B" ) );
1576 domains_ids.add( new DomainId( "A" ) );
1577 domains_ids.add( new DomainId( "B" ) );
1578 domains_ids.add( new DomainId( "B" ) );
1579 domains_ids.add( new DomainId( "A" ) );
1580 domains_ids.add( new DomainId( "B" ) );
1581 domains_ids.add( new DomainId( "C" ) );
1582 domains_ids.add( new DomainId( "A" ) );
1583 domains_ids.add( new DomainId( "C" ) );
1584 domains_ids.add( new DomainId( "D" ) );
1585 if ( !p.contains( domains_ids, false ) ) {
1588 if ( p.contains( domains_ids, true ) ) {
1592 catch ( final Exception e ) {
1593 e.printStackTrace( System.out );
1599 private static boolean testBinaryDomainCombination() {
1601 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "a", "a" );
1602 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "a" );
1603 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "a", "b" );
1604 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "B", "A" );
1605 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "A", "B" );
1606 final BasicBinaryDomainCombination s5 = new BasicBinaryDomainCombination( "c", "a" );
1607 final BasicBinaryDomainCombination s6 = new BasicBinaryDomainCombination( "b", "c" );
1608 final BasicBinaryDomainCombination s7 = new BasicBinaryDomainCombination( "d", "a" );
1609 final BasicBinaryDomainCombination s8 = new BasicBinaryDomainCombination( "b", "d" );
1610 final BinaryDomainCombination s9 = BasicBinaryDomainCombination.createInstance( " z-z=a-aa " );
1611 if ( !s9.toString().equals( "a-aa=z-z" ) ) {
1612 System.out.println( s9.toString() );
1615 if ( !s0.equals( s0 ) ) {
1618 if ( s0.equals( s1 ) ) {
1621 if ( s1.equals( s0 ) ) {
1624 if ( !s1.equals( s2 ) ) {
1627 if ( !s2.equals( s1 ) ) {
1630 if ( s2.equals( s3 ) ) {
1633 if ( s2.equals( s3 ) ) {
1636 if ( s2.equals( s4 ) ) {
1639 final SortedSet<BasicBinaryDomainCombination> sorted = new TreeSet<BasicBinaryDomainCombination>();
1652 if ( sorted.size() != 6 ) {
1655 final DirectedBinaryDomainCombination aa = new DirectedBinaryDomainCombination( "a", "a" );
1656 final DirectedBinaryDomainCombination ba = new DirectedBinaryDomainCombination( "b", "a" );
1657 final DirectedBinaryDomainCombination ab = new DirectedBinaryDomainCombination( "a", "b" );
1658 final DirectedBinaryDomainCombination bb = new DirectedBinaryDomainCombination( "b", "b" );
1659 if ( !aa.equals( aa ) ) {
1662 if ( aa.equals( bb ) ) {
1665 if ( ab.equals( ba ) ) {
1668 if ( ba.equals( ab ) ) {
1671 if ( !ab.equals( ab ) ) {
1674 if ( ab.equals( aa ) ) {
1677 if ( ab.equals( bb ) ) {
1681 catch ( final Exception e ) {
1682 e.printStackTrace( System.out );
1688 private static boolean testBinaryStateMatrixToGainLossMatrix( final File test_dir ) {
1689 final BinaryStates I = BinaryStates.PRESENT;
1690 final BinaryStates O = BinaryStates.ABSENT;
1692 final CharacterStateMatrix<BinaryStates> binary_states_matrix_0 = new BasicCharacterStateMatrix<BinaryStates>( 7,
1694 binary_states_matrix_0.setIdentifier( 0, "A" );
1695 binary_states_matrix_0.setIdentifier( 1, "B" );
1696 binary_states_matrix_0.setIdentifier( 2, "C" );
1697 binary_states_matrix_0.setIdentifier( 3, "D" );
1698 binary_states_matrix_0.setIdentifier( 4, "1" );
1699 binary_states_matrix_0.setIdentifier( 5, "2" );
1700 binary_states_matrix_0.setIdentifier( 6, "3" );
1701 binary_states_matrix_0.setState( 0, 0, O );
1702 binary_states_matrix_0.setState( 1, 0, O );
1703 binary_states_matrix_0.setState( 2, 0, O );
1704 binary_states_matrix_0.setState( 3, 0, O );
1705 binary_states_matrix_0.setState( 4, 0, O );
1706 binary_states_matrix_0.setState( 5, 0, O );
1707 binary_states_matrix_0.setState( 6, 0, O );
1708 binary_states_matrix_0.setState( 0, 1, I );
1709 binary_states_matrix_0.setState( 1, 1, O );
1710 binary_states_matrix_0.setState( 2, 1, O );
1711 binary_states_matrix_0.setState( 3, 1, O );
1712 binary_states_matrix_0.setState( 4, 1, O );
1713 binary_states_matrix_0.setState( 5, 1, O );
1714 binary_states_matrix_0.setState( 6, 1, O );
1715 binary_states_matrix_0.setState( 0, 2, O );
1716 binary_states_matrix_0.setState( 1, 2, O );
1717 binary_states_matrix_0.setState( 2, 2, O );
1718 binary_states_matrix_0.setState( 3, 2, O );
1719 binary_states_matrix_0.setState( 4, 2, I );
1720 binary_states_matrix_0.setState( 5, 2, O );
1721 binary_states_matrix_0.setState( 6, 2, O );
1722 binary_states_matrix_0.setState( 0, 3, I );
1723 binary_states_matrix_0.setState( 1, 3, O );
1724 binary_states_matrix_0.setState( 2, 3, O );
1725 binary_states_matrix_0.setState( 3, 3, O );
1726 binary_states_matrix_0.setState( 4, 3, I );
1727 binary_states_matrix_0.setState( 5, 3, O );
1728 binary_states_matrix_0.setState( 6, 3, I );
1729 binary_states_matrix_0.setState( 0, 4, I );
1730 binary_states_matrix_0.setState( 1, 4, O );
1731 binary_states_matrix_0.setState( 2, 4, I );
1732 binary_states_matrix_0.setState( 3, 4, O );
1733 binary_states_matrix_0.setState( 4, 4, I );
1734 binary_states_matrix_0.setState( 5, 4, O );
1735 binary_states_matrix_0.setState( 6, 4, I );
1736 binary_states_matrix_0.setState( 0, 5, I );
1737 binary_states_matrix_0.setState( 1, 5, I );
1738 binary_states_matrix_0.setState( 2, 5, I );
1739 binary_states_matrix_0.setState( 3, 5, I );
1740 binary_states_matrix_0.setState( 4, 5, I );
1741 binary_states_matrix_0.setState( 5, 5, I );
1742 binary_states_matrix_0.setState( 6, 5, I );
1743 final String[] character_labels_0 = new String[ 6 ];
1744 character_labels_0[ 0 ] = "first";
1745 character_labels_0[ 1 ] = "second";
1746 character_labels_0[ 2 ] = "third";
1747 character_labels_0[ 3 ] = "forth";
1748 character_labels_0[ 4 ] = "fifth";
1749 character_labels_0[ 5 ] = "sixth";
1750 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1751 final Phylogeny phylogeny_0 = factory.create( "(((A,B)1,C)2,D)3", new NHXParser() )[ 0 ];
1752 final DomainParsimonyCalculator dom_pars = DomainParsimonyCalculator.createInstance( phylogeny_0 );
1753 dom_pars.executeOnGivenBinaryStatesMatrix( binary_states_matrix_0, character_labels_0 );
1754 final CharacterStateMatrix<GainLossStates> gl_matrix_0 = dom_pars.getGainLossMatrix();
1755 // final StringWriter sw = new StringWriter();
1756 // gl_matrix_0.toWriter( sw );
1757 // System.out.println( sw.toString() );
1758 if ( dom_pars.getCost() != 13 ) {
1761 if ( dom_pars.getTotalGains() != 5 ) {
1764 if ( dom_pars.getTotalLosses() != 8 ) {
1767 if ( dom_pars.getTotalUnchanged() != 29 ) {
1770 if ( gl_matrix_0.getState( "A", 1 ) != GainLossStates.GAIN ) {
1773 if ( gl_matrix_0.getState( "A", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1776 if ( gl_matrix_0.getState( "B", 4 ) != GainLossStates.LOSS ) {
1779 if ( gl_matrix_0.getState( "C", 4 ) != GainLossStates.GAIN ) {
1782 if ( gl_matrix_0.getState( "D", 4 ) != GainLossStates.LOSS ) {
1785 if ( gl_matrix_0.getState( "1", 4 ) != GainLossStates.GAIN ) {
1788 if ( gl_matrix_0.getState( "2", 4 ) != GainLossStates.LOSS ) {
1791 if ( gl_matrix_0.getState( "3", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1795 catch ( final Exception e ) {
1796 e.printStackTrace( System.out );
1802 private static boolean testCombinableDomains() {
1804 final Domain key0 = new BasicDomain( "key0", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1805 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1806 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1807 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1808 final CombinableDomains cd0 = new BasicCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
1809 cd0.addCombinableDomain( a.getDomainId() );
1810 cd0.addCombinableDomain( b.getDomainId() );
1811 cd0.addCombinableDomain( b.getDomainId() );
1812 cd0.addCombinableDomain( c.getDomainId() );
1813 cd0.addCombinableDomain( c.getDomainId() );
1814 cd0.addCombinableDomain( c.getDomainId() );
1815 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
1818 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
1821 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
1824 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
1827 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
1830 if ( cd0.getAllDomains().size() != 4 ) {
1833 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
1836 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
1839 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
1842 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
1845 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
1848 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "key0", "a" );
1849 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "key0" );
1850 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "key0", "c" );
1851 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "key0", "cc" );
1852 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "c", "key0" );
1853 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
1856 if ( !cd0.toBinaryDomainCombinations().contains( s1 ) ) {
1859 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
1862 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
1865 if ( !cd0.toBinaryDomainCombinations().contains( s4 ) ) {
1868 final Domain key1 = new BasicDomain( "key1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1869 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1870 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1871 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1872 final CombinableDomains cd1 = new BasicCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
1873 cd1.addCombinableDomain( a1.getDomainId() );
1874 cd1.addCombinableDomain( b1.getDomainId() );
1875 cd1.addCombinableDomain( c1.getDomainId() );
1876 cd1.addCombinableDomain( key1.getDomainId() );
1877 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
1880 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
1883 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
1886 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
1889 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
1892 if ( cd1.getAllDomains().size() != 4 ) {
1895 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
1898 final BasicBinaryDomainCombination kk = new BasicBinaryDomainCombination( "key1", "key1" );
1899 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
1903 catch ( final Exception e ) {
1904 e.printStackTrace( System.out );
1910 private static boolean testCombinationsBasedPairwiseSimilarityCalculator() {
1912 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1913 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1914 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1915 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1916 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1917 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1918 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1919 new BasicSpecies( "rabbit" ) );
1920 one.addCombinableDomain( a.getDomainId() );
1921 one.addCombinableDomain( a.getDomainId() );
1922 two.addCombinableDomain( new BasicDomain( "A", 1, 5, ( short ) 1, ( short ) 4, 0.1, -12 ).getDomainId() );
1923 two.addCombinableDomain( b.getDomainId() );
1924 two.addCombinableDomain( c.getDomainId() );
1925 final PairwiseDomainSimilarityCalculator calc = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1926 final PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1927 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 / ( 1 + 2 ) ) ) {
1930 if ( s1.getDifferenceInCounts() != ( 1 - 3 ) ) {
1933 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s1 ).getNumberOfDifferentDomains() != 2 ) {
1936 one.addCombinableDomain( b.getDomainId() );
1937 one.addCombinableDomain( c.getDomainId() );
1938 final PairwiseDomainSimilarity s2 = calc.calculateSimilarity( one, two );
1939 if ( !TestSurfacing.isEqual( s2.getSimilarityScore(), 3.0 / ( 0 + 3 ) ) ) {
1942 if ( s2.getDifferenceInCounts() != 0 ) {
1945 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s2 ).getNumberOfDifferentDomains() != 0 ) {
1948 final Domain d = new BasicDomain( "D", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1949 final Domain e = new BasicDomain( "E", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1950 final Domain f = new BasicDomain( "F", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1951 one.addCombinableDomain( d.getDomainId() );
1952 one.addCombinableDomain( d.getDomainId() );
1953 one.addCombinableDomain( e.getDomainId() );
1954 one.addCombinableDomain( f.getDomainId() );
1955 final PairwiseDomainSimilarity s3 = calc.calculateSimilarity( one, two );
1956 if ( !TestSurfacing.isEqual( s3.getSimilarityScore(), 3.0 / ( 3 + 3 ) ) ) {
1959 if ( s3.getDifferenceInCounts() != ( 6 - 3 ) ) {
1962 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s3 ).getNumberOfDifferentDomains() != 3 ) {
1965 final Domain aaa = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1966 final Domain bbb = new BasicDomain( "bbb", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1967 final Domain three_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1968 final Domain four_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1969 final CombinableDomains three = new BasicCombinableDomains( three_key.getDomainId(),
1970 new BasicSpecies( "mouse" ) );
1971 final CombinableDomains four = new BasicCombinableDomains( four_key.getDomainId(),
1972 new BasicSpecies( "rabbit" ) );
1973 three.addCombinableDomain( aaa.getDomainId() );
1974 four.addCombinableDomain( bbb.getDomainId() );
1975 final PairwiseDomainSimilarityCalculator calc2 = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1976 final PairwiseDomainSimilarity s4 = calc2.calculateSimilarity( three, four );
1977 if ( !TestSurfacing.isEqual( s4.getSimilarityScore(), 0.0 / ( 0 + 2 ) ) ) {
1980 final Domain aaa2 = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1981 four.addCombinableDomain( aaa2.getDomainId() );
1982 final PairwiseDomainSimilarity s5 = calc.calculateSimilarity( three, four );
1983 if ( !TestSurfacing.isEqual( s5.getSimilarityScore(), 1.0 / ( 1 + 1 ) ) ) {
1987 catch ( final Exception e ) {
1988 e.printStackTrace( System.out );
1994 private static boolean testCopyNumberBasedPairwiseSimilarityCalculator() {
1996 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1997 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1998 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1999 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
2000 new BasicSpecies( "rabbit" ) );
2001 one.setKeyDomainCount( 2 );
2002 two.setKeyDomainCount( 3 );
2003 final PairwiseDomainSimilarityCalculator calc = new DomainCountsBasedPairwiseSimilarityCalculator();
2004 PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
2005 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( ( 3 - 2.0 ) / ( 2 + 3 ) ) ) ) {
2008 if ( s1.getDifferenceInCounts() != ( 2 - 3 ) ) {
2011 one.setKeyDomainCount( 1 );
2012 two.setKeyDomainCount( 1 );
2013 s1 = calc.calculateSimilarity( one, two );
2014 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 ) ) {
2017 if ( s1.getDifferenceInCounts() != ( 1 - 1 ) ) {
2020 one.setKeyDomainCount( 1 );
2021 two.setKeyDomainCount( 1000 );
2022 s1 = calc.calculateSimilarity( one, two );
2023 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 999.0 / 1001 ) ) ) {
2026 if ( s1.getDifferenceInCounts() != ( 1 - 1000 ) ) {
2030 catch ( final Exception e ) {
2031 e.printStackTrace( System.out );
2037 private static boolean testDirectedCombinableDomains() {
2039 final Domain key0 = new BasicDomain( "key0", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 );
2040 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2041 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2042 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2043 final CombinableDomains cd0 = new DirectedCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
2044 cd0.addCombinableDomain( a.getDomainId() );
2045 cd0.addCombinableDomain( b.getDomainId() );
2046 cd0.addCombinableDomain( b.getDomainId() );
2047 cd0.addCombinableDomain( c.getDomainId() );
2048 cd0.addCombinableDomain( c.getDomainId() );
2049 cd0.addCombinableDomain( c.getDomainId() );
2050 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
2053 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
2056 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
2059 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
2062 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
2065 if ( cd0.getAllDomains().size() != 4 ) {
2068 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
2071 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
2074 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
2077 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
2080 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
2083 final BinaryDomainCombination s0 = new DirectedBinaryDomainCombination( "key0", "a" );
2084 final BinaryDomainCombination s1 = new DirectedBinaryDomainCombination( "b", "key0" );
2085 final BinaryDomainCombination s2 = new DirectedBinaryDomainCombination( "key0", "c" );
2086 final BinaryDomainCombination s3 = new DirectedBinaryDomainCombination( "key0", "cc" );
2087 final BinaryDomainCombination s4 = new DirectedBinaryDomainCombination( "a", "b" );
2088 final BinaryDomainCombination s5 = new DirectedBinaryDomainCombination( "b", "a" );
2089 final BinaryDomainCombination s6 = new DirectedBinaryDomainCombination( "key0", "b" );
2090 final BinaryDomainCombination s7 = new DirectedBinaryDomainCombination( "a", "key0" );
2091 final BinaryDomainCombination s8 = new DirectedBinaryDomainCombination( "c", "key0" );
2092 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
2095 if ( cd0.toBinaryDomainCombinations().contains( s1 ) ) {
2098 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
2101 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
2104 if ( cd0.toBinaryDomainCombinations().contains( s4 ) ) {
2107 if ( cd0.toBinaryDomainCombinations().contains( s5 ) ) {
2110 if ( !cd0.toBinaryDomainCombinations().contains( s6 ) ) {
2113 if ( cd0.toBinaryDomainCombinations().contains( s7 ) ) {
2116 if ( cd0.toBinaryDomainCombinations().contains( s8 ) ) {
2119 final Domain key1 = new BasicDomain( "key1", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 );
2120 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2121 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2122 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2123 final CombinableDomains cd1 = new DirectedCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
2124 cd1.addCombinableDomain( a1.getDomainId() );
2125 cd1.addCombinableDomain( b1.getDomainId() );
2126 cd1.addCombinableDomain( c1.getDomainId() );
2127 cd1.addCombinableDomain( key1.getDomainId() );
2128 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
2131 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
2134 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
2137 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
2140 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
2143 if ( cd1.getAllDomains().size() != 4 ) {
2146 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
2149 final BinaryDomainCombination kk = new DirectedBinaryDomainCombination( "key1", "key1" );
2150 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
2154 catch ( final Exception e ) {
2155 e.printStackTrace( System.out );
2161 private static boolean testDirectedness() {
2163 final BinaryStates X = BinaryStates.PRESENT;
2164 final BinaryStates O = BinaryStates.ABSENT;
2165 final GainLossStates G = GainLossStates.GAIN;
2166 final GainLossStates L = GainLossStates.LOSS;
2167 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
2168 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
2169 final Protein one_1 = new BasicProtein( "one", "1", 0 );
2170 final Protein two_1 = new BasicProtein( "two", "1", 0 );
2171 final Protein three_1 = new BasicProtein( "three", "1", 0 );
2172 final Protein four_1 = new BasicProtein( "four", "1", 0 );
2173 final Protein five_1 = new BasicProtein( "five", "1", 0 );
2174 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2175 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2176 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2177 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2178 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2179 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2180 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2181 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2182 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2183 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2184 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2185 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2186 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2187 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2188 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2189 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2190 final List<Protein> list_1 = new ArrayList<Protein>();
2191 list_1.add( one_1 );
2192 list_1.add( two_1 );
2193 list_1.add( three_1 );
2194 list_1.add( four_1 );
2195 list_1.add( five_1 );
2196 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2197 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED );
2198 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "B" ) ) ) {
2201 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "A" ) ) ) {
2204 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "A" ) ) ) {
2207 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "C" ) ) ) {
2210 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "A" ) ) ) {
2213 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "C" ) ) ) {
2216 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "X" ) ) ) {
2219 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2222 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
2225 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2228 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2231 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "A" ) ) ) {
2234 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "B" ) ) ) {
2237 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2240 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2243 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2246 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
2249 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2252 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "N" ) ) ) {
2255 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "M" ) ) ) {
2258 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "P" ) ) ) {
2261 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "P" ) ) ) {
2264 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "N" ) ) ) {
2267 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "M" ) ) ) {
2270 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2273 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2276 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "B" ) ) ) {
2279 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
2280 // gwcd_list.add( gwcd_1 );
2281 // gwcd_list.add( gwcd_2 );
2282 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
2283 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
2284 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
2285 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
2286 // if ( matrix_d.getState( 0, 0 ) != X ) {
2289 // if ( matrix_bc.getState( 0, 0 ) != X ) {
2294 // final BasicCharacterStateMatrix<BinaryStates> dm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
2295 // { X, X, X, X, X, X }, { X, X, X, X, X, X } } );
2296 // if ( !matrix_d.equals( dm ) ) {
2299 // final BasicCharacterStateMatrix<BinaryStates> bcm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
2300 // { X, O, X, X, X, X, O, X, X, O, X, X }, { X, X, X, O, O, O, O, X, O, O, X, X } } );
2301 // if ( !matrix_d.equals( dm ) ) {
2304 //``````````````````````````
2305 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
2306 // gwcd_list.add( one );
2307 // gwcd_list.add( two );
2308 // gwcd_list.add( three );
2309 // gwcd_list.add( four );
2310 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimony
2311 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
2312 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimony
2313 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
2314 // // System.out.println( "d:" );
2315 // // System.out.println(matrix_d.toStringBuffer().toString() );
2316 // // System.out.println( "bc:" );
2317 // // System.out.println(matrix_bc.toStringBuffer().toString() );
2318 // // 1 a b c e f g h l m
2319 // // 2 a b c e f g i n o
2320 // // 3 a b d e f g j p q
2322 // if ( matrix_d.getState( 0, 0 ) != X ) {
2325 // if ( matrix_d.getState( 0, 1 ) != X ) {
2328 // if ( matrix_d.getState( 0, 2 ) != X ) {
2331 // if ( matrix_d.getState( 0, 3 ) != O ) {
2334 // if ( matrix_d.getState( 0, 4 ) != X ) {
2337 // if ( matrix_d.getState( 0, 5 ) != X ) {
2340 // if ( matrix_d.getState( 0, 6 ) != X ) {
2343 // if ( matrix_d.getState( 0, 7 ) != X ) {
2346 // if ( matrix_d.getState( 0, 8 ) != O ) {
2349 // // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
2350 // // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
2351 // // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
2353 // if ( matrix_bc.getState( 0, 0 ) != X ) {
2356 // if ( matrix_bc.getState( 0, 1 ) != X ) {
2359 // if ( matrix_bc.getState( 0, 2 ) != X ) {
2362 // if ( matrix_bc.getState( 0, 3 ) != O ) {
2365 // if ( matrix_bc.getState( 0, 4 ) != X ) {
2368 // if ( matrix_bc.getState( 1, 0 ) != O ) {
2371 // if ( matrix_bc.getState( 1, 1 ) != X ) {
2374 // if ( matrix_bc.getState( 1, 2 ) != X ) {
2377 // if ( matrix_bc.getState( 1, 3 ) != O ) {
2380 // if ( matrix_bc.getState( 1, 4 ) != X ) {
2383 // if ( matrix_bc.getState( 2, 0 ) != O ) {
2386 // if ( matrix_bc.getState( 2, 1 ) != X ) {
2389 // if ( matrix_bc.getState( 2, 2 ) != O ) {
2392 // if ( matrix_bc.getState( 2, 3 ) != X ) {
2395 // if ( matrix_bc.getState( 2, 4 ) != X ) {
2398 // final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
2399 // final String p0_str = "((one,two)1-2,(three,four)3-4)root";
2400 // final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
2401 // final DomainParsimony dp0 = DomainParsimony.createInstance( p0, gwcd_list );
2402 // dp0.executeDolloParsimonyOnDomainPresence();
2403 // final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
2404 // final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
2405 // dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2406 // final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
2407 // final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
2408 // if ( is_matrix_d.getState( "root", "A" ) != X ) {
2411 // if ( is_matrix_d.getState( "root", "B" ) != X ) {
2414 // if ( is_matrix_d.getState( "root", "C" ) != O ) {
2417 // if ( is_matrix_d.getState( "root", "D" ) != O ) {
2420 // if ( is_matrix_d.getState( "root", "E" ) != X ) {
2423 // if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
2426 // if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
2429 // if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
2432 // if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
2435 // if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
2438 // if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
2441 // if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
2444 // if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
2447 // if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
2450 // if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
2453 // if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
2456 // if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
2459 // if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
2462 // if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
2465 // final Protein ab_1 = new BasicProtein( "ab", "one" );
2466 // ab_1.addProteinDomain( a );
2467 // ab_1.addProteinDomain( b );
2468 // final Protein ac_1 = new BasicProtein( "ac", "one" );
2469 // ac_1.addProteinDomain( a );
2470 // ac_1.addProteinDomain( c );
2471 // final Protein de_1 = new BasicProtein( "de", "one" );
2472 // de_1.addProteinDomain( d );
2473 // de_1.addProteinDomain( e );
2474 // final Protein ac_2 = new BasicProtein( "ac", "two" );
2475 // ac_2.addProteinDomain( a );
2476 // ac_2.addProteinDomain( c );
2477 // final Protein ab_3 = new BasicProtein( "ab", "three" );
2478 // ab_3.addProteinDomain( a );
2479 // ab_3.addProteinDomain( b );
2480 // final Protein de_4 = new BasicProtein( "de", "four" );
2481 // de_4.addProteinDomain( d );
2482 // de_4.addProteinDomain( e );
2483 // final Protein ab_6 = new BasicProtein( "ab", "six" );
2484 // ab_6.addProteinDomain( a );
2485 // ab_6.addProteinDomain( b );
2486 // final List<Protein> spec_one = new ArrayList<Protein>();
2487 // final List<Protein> spec_two = new ArrayList<Protein>();
2488 // final List<Protein> spec_three = new ArrayList<Protein>();
2489 // final List<Protein> spec_four = new ArrayList<Protein>();
2490 // final List<Protein> spec_five = new ArrayList<Protein>();
2491 // final List<Protein> spec_six = new ArrayList<Protein>();
2492 // final List<Protein> spec_seven = new ArrayList<Protein>();
2493 // spec_one.add( ab_1 );
2494 // spec_one.add( ac_1 );
2495 // spec_one.add( de_1 );
2496 // spec_two.add( ac_2 );
2497 // spec_three.add( ab_3 );
2498 // spec_four.add( de_4 );
2499 // spec_six.add( ab_6 );
2500 // final GenomeWideCombinableDomains one_gwcd = BasicGenomeWideCombinableDomains
2501 // .createInstance( spec_one, false, new BasicSpecies( "one" ), false );
2502 // final GenomeWideCombinableDomains two_gwcd = BasicGenomeWideCombinableDomains
2503 // .createInstance( spec_two, false, new BasicSpecies( "two" ), false );
2504 // final GenomeWideCombinableDomains three_gwcd = BasicGenomeWideCombinableDomains
2505 // .createInstance( spec_three, false, new BasicSpecies( "three" ), false );
2506 // final GenomeWideCombinableDomains four_gwcd = BasicGenomeWideCombinableDomains
2507 // .createInstance( spec_four, false, new BasicSpecies( "four" ), false );
2508 // final GenomeWideCombinableDomains five_gwcd = BasicGenomeWideCombinableDomains
2509 // .createInstance( spec_five, false, new BasicSpecies( "five" ), false );
2510 // final GenomeWideCombinableDomains six_gwcd = BasicGenomeWideCombinableDomains
2511 // .createInstance( spec_six, false, new BasicSpecies( "six" ), false );
2512 // final GenomeWideCombinableDomains seven_gwcd = BasicGenomeWideCombinableDomains
2513 // .createInstance( spec_seven, false, new BasicSpecies( "seven" ), false
2515 // final List<GenomeWideCombinableDomains> gwcd_list1 = new ArrayList<GenomeWideCombinableDomains>();
2516 // gwcd_list1.add( one_gwcd );
2517 // gwcd_list1.add( two_gwcd );
2518 // gwcd_list1.add( three_gwcd );
2519 // gwcd_list1.add( four_gwcd );
2520 // gwcd_list1.add( five_gwcd );
2521 // gwcd_list1.add( six_gwcd );
2522 // gwcd_list1.add( seven_gwcd );
2523 // final PhylogenyFactory factory1 = ParserBasedPhylogenyFactory.getInstance();
2524 // final String p1_str = "(((((one,two)12,three)123,(four,five)45)12345,six)123456,seven)root";
2525 // final Phylogeny p1 = factory1.create( p1_str, new NHXParser() )[ 0 ];
2526 // final DomainParsimony dp1 = DomainParsimony.createInstance( p1, gwcd_list1 );
2527 // dp1.executeDolloParsimonyOnDomainPresence();
2528 // final CharacterStateMatrix<GainLossStates> gl_dollo_d = dp1.getGainLossMatrix();
2529 // final CharacterStateMatrix<BinaryStates> i_dollo_d = dp1.getInternalStatesMatrix();
2530 // if ( dp1.getCost() != 14 ) {
2533 // if ( dp1.getTotalGains() != 5 ) {
2536 // if ( dp1.getTotalLosses() != 9 ) {
2539 // if ( dp1.getTotalUnchanged() != 51 ) {
2542 // if ( dp1.getNetGainsOnNode( "45" ) != -2 ) {
2545 // if ( dp1.getSumOfGainsOnNode( "45" ) != 0 ) {
2548 // if ( dp1.getSumOfLossesOnNode( "45" ) != 2 ) {
2551 // if ( dp1.getSumOfUnchangedOnNode( "45" ) != 3 ) {
2554 // if ( dp1.getSumOfUnchangedPresentOnNode( "45" ) != 2 ) {
2557 // if ( dp1.getSumOfUnchangedAbsentOnNode( "45" ) != 1 ) {
2560 // if ( dp1.getUnitsGainedOnNode( "45" ).contains( "A" ) ) {
2563 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A" ) ) {
2566 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "B" ) ) {
2569 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D" ) ) {
2572 // if ( !dp1.getUnitsOnNode( "12" ).contains( "A" ) ) {
2575 // if ( !dp1.getUnitsOnNode( "12" ).contains( "B" ) ) {
2578 // if ( !dp1.getUnitsOnNode( "12" ).contains( "C" ) ) {
2581 // if ( !dp1.getUnitsOnNode( "12" ).contains( "D" ) ) {
2584 // if ( !dp1.getUnitsOnNode( "12" ).contains( "E" ) ) {
2587 // if ( dp1.getNetGainsOnNode( "123456" ) != 2 ) {
2590 // if ( dp1.getSumOfGainsOnNode( "123456" ) != 2 ) {
2593 // dp1.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2594 // final CharacterStateMatrix<GainLossStates> gl_dollo_bc = dp1.getGainLossMatrix();
2595 // final CharacterStateMatrix<BinaryStates> i_dollo_bc = dp1.getInternalStatesMatrix();
2596 // if ( dp1.getCost() != 8 ) {
2599 // if ( dp1.getTotalGains() != 3 ) {
2602 // if ( dp1.getTotalLosses() != 5 ) {
2605 // if ( dp1.getTotalUnchanged() != 31 ) {
2608 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2611 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D=E" ) ) {
2614 // dp1.executeFitchParsimonyOnDomainPresence();
2615 // final CharacterStateMatrix<GainLossStates> gl_fitch_d = dp1.getGainLossMatrix();
2616 // final CharacterStateMatrix<BinaryStates> i_fitch_d = dp1.getInternalStatesMatrix();
2617 // if ( dp1.getCost() != 10 ) {
2620 // if ( dp1.getTotalGains() != 7 ) {
2623 // if ( dp1.getTotalLosses() != 3 ) {
2626 // if ( dp1.getTotalUnchanged() != 55 ) {
2629 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "E" ) ) {
2632 // dp1.executeFitchParsimonyOnBinaryDomainCombintion();
2633 // final CharacterStateMatrix<GainLossStates> gl_fitch_bc = dp1.getGainLossMatrix();
2634 // final CharacterStateMatrix<BinaryStates> i_fitch_bc = dp1.getInternalStatesMatrix();
2635 // if ( dp1.getCost() != 6 ) {
2638 // if ( dp1.getTotalGains() != 4 ) {
2641 // if ( dp1.getTotalLosses() != 2 ) {
2644 // if ( dp1.getTotalUnchanged() != 33 ) {
2647 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2650 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "D=E" ) ) {
2653 // if ( dp1.getNetGainsOnNode( "two" ) != -1 ) {
2656 // if ( dp1.getNetGainsOnNode( "123" ) != 0 ) {
2659 // if ( dp1.getSumOfUnchangedPresentOnNode( "123" ) != 1 ) {
2662 // if ( dp1.getSumOfUnchangedAbsentOnNode( "123" ) != 2 ) {
2665 // if ( dp1.getSumOfUnchangedOnNode( "123" ) != 3 ) {
2668 // if ( dp1.getSumOfUnchangedOnNode( "two" ) != 2 ) {
2671 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "two" ).contains( "D=E" ) ) {
2674 // if ( !dp1.getUnitsUnchangedPresentOnNode( "two" ).contains( "A=C" ) ) {
2677 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "A=C" ) ) {
2680 // if ( !dp1.getUnitsUnchangedPresentOnNode( "123" ).contains( "A=B" ) ) {
2683 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "D=E" ) ) {
2686 // CharacterStateMatrix<BinaryStates> bsm = null;
2687 // CharacterStateMatrix<GainLossStates> glm = null;
2688 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, X, X },
2689 // { 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 } } );
2690 // if ( !bsm.equals( i_dollo_d ) ) {
2693 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, O, O },
2694 // { 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 } } );
2695 // if ( !bsm.equals( i_fitch_d ) ) {
2698 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, P, P },
2699 // { 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 },
2700 // { 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 },
2701 // { A, A, A, A, A }, { A, A, A, A, A } } );
2702 // if ( !glm.equals( gl_dollo_d ) ) {
2705 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, G, G },
2706 // { 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 },
2707 // { 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 },
2708 // { A, A, A, A, A }, { A, A, A, A, A } } );
2709 // if ( !glm.equals( gl_fitch_d ) ) {
2712 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X }, { X, O, X },
2713 // { O, O, X }, { X, O, X }, { X, O, O }, { O, O, O } } );
2714 // if ( !bsm.equals( i_dollo_bc ) ) {
2717 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, O }, { X, O, O },
2718 // { O, O, O }, { X, O, O }, { X, O, O }, { O, O, O } } );
2719 // if ( !bsm.equals( i_fitch_bc ) ) {
2722 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P }, { L, P, L },
2723 // { P, G, P }, { P, A, L }, { P, A, P }, { A, A, P }, { A, A, L }, { L, A, P }, { P, A, G },
2724 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2725 // if ( !glm.equals( gl_dollo_bc ) ) {
2728 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, G }, { L, P, A },
2729 // { P, G, A }, { P, A, A }, { P, A, A }, { A, A, G }, { A, A, A }, { L, A, A }, { P, A, A },
2730 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2731 // if ( !glm.equals( gl_fitch_bc ) ) {
2735 catch ( final Exception e ) {
2736 e.printStackTrace( System.out );
2742 private static boolean testDirectednessAndAdjacency() {
2744 final Protein one_1 = new BasicProtein( "one", "1", 0 );
2745 final Protein two_1 = new BasicProtein( "two", "1", 0 );
2746 final Protein three_1 = new BasicProtein( "three", "1", 0 );
2747 final Protein four_1 = new BasicProtein( "four", "1", 0 );
2748 final Protein five_1 = new BasicProtein( "five", "1", 0 );
2749 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2750 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2751 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2752 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2753 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2754 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2755 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2756 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2757 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2758 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2759 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2760 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2761 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2762 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2763 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2764 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2765 final List<Protein> list_1 = new ArrayList<Protein>();
2766 list_1.add( one_1 );
2767 list_1.add( two_1 );
2768 list_1.add( three_1 );
2769 list_1.add( four_1 );
2770 list_1.add( five_1 );
2771 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2772 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED_ADJACTANT );
2773 if ( !gwcd_1.toBinaryDomainCombinations()
2774 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "B" ) ) ) {
2777 if ( gwcd_1.toBinaryDomainCombinations()
2778 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "A" ) ) ) {
2781 if ( gwcd_1.toBinaryDomainCombinations()
2782 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "A" ) ) ) {
2785 if ( gwcd_1.toBinaryDomainCombinations()
2786 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "C" ) ) ) {
2789 if ( gwcd_1.toBinaryDomainCombinations()
2790 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "A" ) ) ) {
2793 if ( !gwcd_1.toBinaryDomainCombinations()
2794 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "C" ) ) ) {
2797 if ( !gwcd_1.toBinaryDomainCombinations()
2798 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "X" ) ) ) {
2801 if ( gwcd_1.toBinaryDomainCombinations()
2802 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2805 if ( !gwcd_1.toBinaryDomainCombinations()
2806 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2809 if ( gwcd_1.toBinaryDomainCombinations()
2810 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2813 if ( gwcd_1.toBinaryDomainCombinations()
2814 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2817 if ( !gwcd_1.toBinaryDomainCombinations()
2818 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2821 if ( gwcd_1.toBinaryDomainCombinations()
2822 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "A" ) ) ) {
2825 if ( gwcd_1.toBinaryDomainCombinations()
2826 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "B" ) ) ) {
2829 if ( !gwcd_1.toBinaryDomainCombinations()
2830 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2833 if ( gwcd_1.toBinaryDomainCombinations()
2834 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2837 if ( gwcd_1.toBinaryDomainCombinations()
2838 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2841 if ( gwcd_1.toBinaryDomainCombinations()
2842 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2845 if ( gwcd_1.toBinaryDomainCombinations()
2846 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2849 if ( !gwcd_1.toBinaryDomainCombinations()
2850 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "N" ) ) ) {
2853 if ( !gwcd_1.toBinaryDomainCombinations()
2854 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "M" ) ) ) {
2857 if ( !gwcd_1.toBinaryDomainCombinations()
2858 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "P" ) ) ) {
2861 if ( gwcd_1.toBinaryDomainCombinations()
2862 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "P" ) ) ) {
2865 if ( gwcd_1.toBinaryDomainCombinations()
2866 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "N" ) ) ) {
2869 if ( gwcd_1.toBinaryDomainCombinations()
2870 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "M" ) ) ) {
2873 if ( gwcd_1.toBinaryDomainCombinations()
2874 .contains( new AdjactantDirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2877 if ( gwcd_1.toBinaryDomainCombinations()
2878 .contains( new AdjactantDirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2881 if ( gwcd_1.toBinaryDomainCombinations()
2882 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "B" ) ) ) {
2886 catch ( final Exception e ) {
2887 e.printStackTrace( System.out );
2893 private static boolean testDomainArchitectureBasedGenomeSimilarityCalculator() {
2895 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2896 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2897 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2898 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2899 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2900 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2901 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2902 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2903 final Domain i = new BasicDomain( "i", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2904 final Domain j = new BasicDomain( "j", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2905 final Domain k = new BasicDomain( "k", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2906 final Domain l = new BasicDomain( "l", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2907 final Domain m = new BasicDomain( "m", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2908 final Domain n = new BasicDomain( "n", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2909 final Protein eel_0 = new BasicProtein( "0", "eel", 0 );
2910 final Protein eel_1 = new BasicProtein( "1", "eel", 0 );
2911 final Protein eel_2 = new BasicProtein( "2", "eel", 0 );
2912 final Protein eel_3 = new BasicProtein( "3", "eel", 0 );
2913 final Protein eel_4 = new BasicProtein( "4", "eel", 0 );
2914 final Protein eel_5 = new BasicProtein( "5", "eel", 0 );
2915 final Protein eel_6 = new BasicProtein( "6", "eel", 0 );
2916 final Protein rat_0 = new BasicProtein( "0", "rat", 0 );
2917 final Protein rat_1 = new BasicProtein( "1", "rat", 0 );
2918 final Protein rat_2 = new BasicProtein( "2", "rat", 0 );
2919 final Protein rat_3 = new BasicProtein( "3", "rat", 0 );
2920 final Protein rat_4 = new BasicProtein( "4", "rat", 0 );
2921 final Protein rat_5 = new BasicProtein( "5", "rat", 0 );
2922 final Protein rat_6 = new BasicProtein( "6", "rat", 0 );
2923 final Protein rat_7 = new BasicProtein( "7", "rat", 0 );
2924 eel_1.addProteinDomain( a );
2925 eel_2.addProteinDomain( a );
2926 eel_2.addProteinDomain( b );
2927 eel_3.addProteinDomain( a );
2928 eel_3.addProteinDomain( a );
2929 eel_3.addProteinDomain( b );
2930 eel_4.addProteinDomain( a );
2931 eel_4.addProteinDomain( b );
2932 eel_4.addProteinDomain( c );
2933 eel_4.addProteinDomain( d );
2934 eel_4.addProteinDomain( e );
2935 eel_5.addProteinDomain( e );
2936 eel_5.addProteinDomain( e );
2937 eel_5.addProteinDomain( f );
2938 eel_5.addProteinDomain( f );
2939 eel_5.addProteinDomain( f );
2940 eel_5.addProteinDomain( f );
2941 eel_6.addProteinDomain( g );
2942 eel_6.addProteinDomain( h );
2943 rat_1.addProteinDomain( a );
2944 rat_2.addProteinDomain( a );
2945 rat_2.addProteinDomain( b );
2946 rat_3.addProteinDomain( a );
2947 rat_3.addProteinDomain( a );
2948 rat_3.addProteinDomain( b );
2949 rat_4.addProteinDomain( a );
2950 rat_4.addProteinDomain( b );
2951 rat_4.addProteinDomain( c );
2952 rat_4.addProteinDomain( i );
2953 rat_4.addProteinDomain( l );
2954 rat_5.addProteinDomain( i );
2955 rat_5.addProteinDomain( f );
2956 rat_5.addProteinDomain( f );
2957 rat_6.addProteinDomain( j );
2958 rat_6.addProteinDomain( k );
2959 rat_7.addProteinDomain( m );
2960 rat_7.addProteinDomain( n );
2961 final List<Protein> protein_list_eel = new ArrayList<Protein>();
2962 protein_list_eel.add( eel_0 );
2963 protein_list_eel.add( eel_1 );
2964 protein_list_eel.add( eel_2 );
2965 protein_list_eel.add( eel_3 );
2966 protein_list_eel.add( eel_4 );
2967 protein_list_eel.add( eel_5 );
2968 protein_list_eel.add( eel_6 );
2969 final List<Protein> protein_list_rat = new ArrayList<Protein>();
2970 protein_list_rat.add( rat_0 );
2971 protein_list_rat.add( rat_1 );
2972 protein_list_rat.add( rat_2 );
2973 protein_list_rat.add( rat_3 );
2974 protein_list_rat.add( rat_4 );
2975 protein_list_rat.add( rat_5 );
2976 protein_list_rat.add( rat_6 );
2977 protein_list_rat.add( rat_7 );
2978 final GenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
2979 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
2980 final GenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
2981 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
2982 final GenomeWideCombinableDomains rat_not_ignore = BasicGenomeWideCombinableDomains
2983 .createInstance( protein_list_rat, false, new BasicSpecies( "rat" ) );
2984 final GenomeWideCombinableDomains rat_ignore = BasicGenomeWideCombinableDomains
2985 .createInstance( protein_list_rat, true, new BasicSpecies( "rat" ) );
2986 final DomainArchitectureBasedGenomeSimilarityCalculator calc_ni = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_not_ignore,
2988 final DomainArchitectureBasedGenomeSimilarityCalculator calc_i = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_ignore,
2990 if ( calc_ni.getAllDomains().size() != 14 ) {
2993 if ( calc_i.getAllDomains().size() != 14 ) {
2996 if ( calc_ni.getDomainsSpecificToGenome0().size() != 4 ) {
2999 if ( calc_i.getDomainsSpecificToGenome0().size() != 4 ) {
3002 if ( calc_ni.getDomainsSpecificToGenome1().size() != 6 ) {
3005 if ( calc_i.getDomainsSpecificToGenome1().size() != 6 ) {
3008 if ( calc_i.getSharedDomains().size() != 4 ) {
3011 if ( calc_ni.getSharedDomains().size() != 4 ) {
3014 if ( !calc_ni.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
3017 if ( !calc_ni.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
3020 if ( !calc_ni.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
3023 if ( !calc_ni.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
3026 if ( calc_ni.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
3029 if ( calc_ni.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
3032 if ( !calc_i.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
3035 if ( !calc_i.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
3038 if ( !calc_i.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
3041 if ( !calc_i.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
3044 if ( calc_i.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
3047 if ( calc_i.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
3050 if ( !calc_ni.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
3053 if ( !calc_ni.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
3056 if ( !calc_ni.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
3059 if ( !calc_ni.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
3062 if ( !calc_ni.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
3065 if ( !calc_ni.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
3068 if ( calc_ni.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
3071 if ( calc_ni.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
3074 if ( calc_ni.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
3077 if ( !calc_i.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
3080 if ( !calc_i.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
3083 if ( !calc_i.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
3086 if ( !calc_i.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
3089 if ( !calc_i.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
3092 if ( !calc_i.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
3095 if ( calc_i.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
3098 if ( calc_i.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
3101 if ( calc_i.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
3104 if ( !calc_i.getSharedDomains().contains( a.getDomainId() ) ) {
3107 if ( !calc_i.getSharedDomains().contains( b.getDomainId() ) ) {
3110 if ( !calc_i.getSharedDomains().contains( c.getDomainId() ) ) {
3113 if ( !calc_i.getSharedDomains().contains( f.getDomainId() ) ) {
3116 final Set<DomainId> all = calc_ni.getAllDomains();
3117 if ( !all.contains( a.getDomainId() ) ) {
3120 if ( !all.contains( b.getDomainId() ) ) {
3123 if ( !all.contains( c.getDomainId() ) ) {
3126 if ( !all.contains( d.getDomainId() ) ) {
3129 if ( !all.contains( e.getDomainId() ) ) {
3132 if ( !all.contains( f.getDomainId() ) ) {
3135 if ( !all.contains( g.getDomainId() ) ) {
3138 if ( !all.contains( h.getDomainId() ) ) {
3141 if ( !all.contains( i.getDomainId() ) ) {
3144 if ( !all.contains( l.getDomainId() ) ) {
3147 if ( !all.contains( j.getDomainId() ) ) {
3150 if ( !all.contains( k.getDomainId() ) ) {
3153 if ( !all.contains( m.getDomainId() ) ) {
3156 if ( !all.contains( n.getDomainId() ) ) {
3159 final Set<BinaryDomainCombination> s_0_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome0();
3160 final Set<BinaryDomainCombination> s_0_i = calc_i.getBinaryDomainCombinationsSpecificToGenome0();
3161 final Set<BinaryDomainCombination> s_1_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome1();
3162 final Set<BinaryDomainCombination> s_1_i = calc_i.getBinaryDomainCombinationsSpecificToGenome1();
3163 final Set<BinaryDomainCombination> a_ni = calc_ni.getAllBinaryDomainCombinations();
3164 final Set<BinaryDomainCombination> a_i = calc_i.getAllBinaryDomainCombinations();
3165 final Set<BinaryDomainCombination> shared_ni = calc_ni.getSharedBinaryDomainCombinations();
3166 final Set<BinaryDomainCombination> shared_i = calc_i.getSharedBinaryDomainCombinations();
3167 if ( a_ni.size() != 25 ) {
3170 if ( a_i.size() != 22 ) {
3173 if ( s_0_ni.size() != 10 ) {
3176 if ( s_0_i.size() != 9 ) {
3179 if ( s_1_ni.size() != 10 ) {
3182 if ( s_1_i.size() != 10 ) {
3185 if ( shared_ni.size() != 5 ) {
3188 if ( shared_i.size() != 3 ) {
3191 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3194 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
3197 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3200 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3203 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3206 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3209 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3212 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3215 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3218 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3221 if ( !a_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3224 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3227 if ( !a_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3230 if ( !a_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3233 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3236 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3239 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3242 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3245 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3248 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3251 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3254 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "l" ) ) ) {
3257 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3260 if ( !a_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3263 if ( !a_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3266 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
3269 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "m" ) ) ) {
3272 if ( a_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3275 if ( a_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3278 if ( a_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3281 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3284 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3287 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3290 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3293 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3296 if ( shared_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3299 if ( shared_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3302 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3305 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3308 if ( !shared_i.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3311 if ( shared_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3314 if ( shared_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3317 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3320 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3323 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3326 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3329 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3332 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3335 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3338 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3341 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3344 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3347 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3350 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3353 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3356 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3359 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3362 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3365 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3368 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3371 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3374 if ( s_0_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3377 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3380 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3383 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3386 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3389 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3392 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3395 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3398 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3401 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3404 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3407 if ( s_1_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3410 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3413 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3416 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3419 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3422 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3425 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3428 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3431 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3434 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3437 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3440 if ( s_1_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3443 if ( !isEqual( calc_ni.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3444 1.0 - ( ( 25.0 - 5.0 ) / 25.0 ) ) ) {
3447 if ( !isEqual( calc_i.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3448 1.0 - ( ( 22.0 - 3.0 ) / 22.0 ) ) ) {
3451 if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 14.0 - 4.0 ) / 14.0 ) ) ) {
3454 if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 14.0 - 4.0 ) / 14.0 ) ) ) {
3457 final Domain u = new BasicDomain( "u", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3458 final Domain v = new BasicDomain( "v", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3459 final Domain w = new BasicDomain( "w", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3460 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3461 final Domain y = new BasicDomain( "y", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3462 final Domain z = new BasicDomain( "z", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3463 final Protein a_0 = new BasicProtein( "0", "a", 0 );
3464 final Protein a_1 = new BasicProtein( "1", "a", 0 );
3465 final Protein a_2 = new BasicProtein( "2", "a", 0 );
3466 final Protein b_0 = new BasicProtein( "0", "b", 0 );
3467 final Protein b_1 = new BasicProtein( "1", "b", 0 );
3468 a_0.addProteinDomain( u );
3469 a_0.addProteinDomain( v );
3470 a_0.addProteinDomain( w );
3471 a_1.addProteinDomain( w );
3472 a_1.addProteinDomain( x );
3473 a_2.addProteinDomain( y );
3474 a_2.addProteinDomain( z );
3475 b_0.addProteinDomain( u );
3476 b_0.addProteinDomain( w );
3477 b_1.addProteinDomain( y );
3478 b_1.addProteinDomain( z );
3479 final List<Protein> protein_list_a = new ArrayList<Protein>();
3480 protein_list_a.add( a_0 );
3481 protein_list_a.add( a_1 );
3482 protein_list_a.add( a_2 );
3483 final List<Protein> protein_list_b = new ArrayList<Protein>();
3484 protein_list_b.add( b_0 );
3485 protein_list_b.add( b_1 );
3486 final GenomeWideCombinableDomains ca = BasicGenomeWideCombinableDomains
3487 .createInstance( protein_list_a, false, new BasicSpecies( "a" ) );
3488 final GenomeWideCombinableDomains cb = BasicGenomeWideCombinableDomains
3489 .createInstance( protein_list_b, true, new BasicSpecies( "b" ) );
3490 final DomainArchitectureBasedGenomeSimilarityCalculator calc_u = new DomainArchitectureBasedGenomeSimilarityCalculator( ca,
3492 calc_u.setAllowDomainsToBeIgnored( true );
3493 if ( calc_u.getAllDomains().size() != 6 ) {
3496 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3499 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3502 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3505 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3508 if ( calc_u.getSharedDomains().size() != 4 ) {
3511 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3514 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3517 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3520 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3523 if ( calc_u.getAllDomains().size() != 6 ) {
3526 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3529 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3532 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3535 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3538 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3541 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3544 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 3 ) {
3547 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3550 if ( calc_u.getSharedBinaryDomainCombinations().size() != 2 ) {
3553 if ( calc_u.getAllBinaryDomainCombinations().size() != 5 ) {
3556 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3557 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3560 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3561 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3564 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3565 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3568 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3571 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3574 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3577 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3580 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3583 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3586 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3589 calc_u.setAllowDomainsToBeIgnored( true );
3590 calc_u.addDomainIdToIgnore( u.getDomainId() );
3591 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3592 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3593 if ( calc_u.getAllDomains().size() != 5 ) {
3596 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3599 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3602 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3605 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3608 if ( calc_u.getSharedDomains().size() != 3 ) {
3611 if ( calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3614 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3617 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3620 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3623 if ( calc_u.getAllDomains().size() != 5 ) {
3626 if ( calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3629 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3632 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3635 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3638 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3641 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3644 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 2 ) {
3647 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3650 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3653 if ( calc_u.getAllBinaryDomainCombinations().size() != 3 ) {
3656 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3657 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3660 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3661 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3664 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3665 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3668 if ( calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3671 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3674 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3677 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3680 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3683 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3686 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3689 calc_u.setAllowDomainsToBeIgnored( false );
3690 if ( calc_u.getAllDomains().size() != 6 ) {
3694 calc_u.setAllowDomainsToBeIgnored( true );
3695 calc_u.deleteAllDomainIdsToIgnore();
3696 calc_u.addDomainIdToIgnore( new DomainId( "v" ) );
3697 calc_u.addDomainIdToIgnore( new DomainId( "w" ) );
3698 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3699 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3700 if ( calc_u.getAllDomains().size() != 4 ) {
3703 if ( calc_u.getDomainsSpecificToGenome0().size() != 1 ) {
3706 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3709 if ( calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3712 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3715 if ( calc_u.getSharedDomains().size() != 3 ) {
3718 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3721 if ( calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3724 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3727 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3730 if ( calc_u.getAllDomains().size() != 4 ) {
3733 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3736 if ( calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3739 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3742 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3745 if ( calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3748 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3751 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 0 ) {
3754 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3757 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3760 if ( calc_u.getAllBinaryDomainCombinations().size() != 1 ) {
3763 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "y", "z" ) ) ) {
3766 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
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.setAllowDomainsToBeIgnored( false );
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 ) ) ) {
3784 calc_u.setAllowDomainsToBeIgnored( true );
3785 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3786 1.0 - ( ( 1.0 - 1.0 ) / 1.0 ) ) ) {
3789 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 4.0 - 3.0 ) / 4.0 ) ) ) {
3792 calc_u.deleteAllDomainIdsToIgnore();
3793 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3794 1.0 - ( ( 5.0 - 2.0 ) / 5.0 ) ) ) {
3797 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 6.0 - 4.0 ) / 6.0 ) ) ) {
3801 catch ( final Exception e ) {
3802 e.printStackTrace( System.out );
3808 private static boolean testDomainCombinationCounting( final File test_dir ) {
3810 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
3811 + ForesterUtil.getFileSeparator() + "hmmpfam_output2" ), "human", "ls" );
3812 parser.setEValueMaximum( 0.2 );
3813 parser.setIgnoreDufs( true );
3814 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
3815 final List<Protein> domain_collections = parser.parse();
3816 final BasicGenomeWideCombinableDomains cdcc = BasicGenomeWideCombinableDomains
3817 .createInstance( domain_collections, false, new BasicSpecies( "human" ) );
3818 CombinableDomains cd = cdcc.get( new DomainId( "A" ) );
3819 if ( cd.getKeyDomainCount() != 9 ) {
3822 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3825 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3828 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 2 ) {
3831 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
3834 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3837 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3840 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3843 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3846 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3849 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3852 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3855 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3858 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3861 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3864 if ( cd.getKeyDomainCount() != 9 ) {
3867 cd = cdcc.get( new DomainId( "B" ) );
3868 if ( cd.getKeyDomainCount() != 12 ) {
3871 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3874 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3877 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 6 ) {
3880 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3883 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3886 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3889 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3892 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3895 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3898 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3901 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3904 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3907 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3910 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3913 if ( cd.getKeyDomainCount() != 12 ) {
3916 cd = cdcc.get( new DomainId( "C" ) );
3917 if ( cd.getKeyDomainCount() != 10 ) {
3920 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3923 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3926 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 4 ) {
3929 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3932 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 2 ) {
3935 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3938 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3941 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3944 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3947 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3950 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 2 ) {
3953 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 2 ) {
3956 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 2 ) {
3959 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3962 cd = cdcc.get( new DomainId( "D" ) );
3963 if ( cd.getKeyDomainCount() != 15 ) {
3966 if ( cd.getKeyDomainProteinsCount() != 6 ) {
3969 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3972 cd = cdcc.get( new DomainId( "E" ) );
3973 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3976 if ( cd.getKeyDomainCount() != 1 ) {
3979 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3982 cd = cdcc.get( new DomainId( "U" ) );
3983 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3986 if ( cd.getKeyDomainCount() != 6 ) {
3989 if ( cd.getKeyDomainProteinsCount() != 3 ) {
3992 cd = cdcc.get( new DomainId( "V" ) );
3993 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3996 if ( cd.getKeyDomainCount() != 3 ) {
3999 if ( cd.getKeyDomainProteinsCount() != 2 ) {
4002 cd = cdcc.get( new DomainId( "W" ) );
4003 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4006 if ( cd.getKeyDomainCount() != 2 ) {
4009 if ( cd.getKeyDomainProteinsCount() != 2 ) {
4012 cd = cdcc.get( new DomainId( "X" ) );
4013 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4016 if ( cd.getKeyDomainCount() != 2 ) {
4019 cd = cdcc.get( new DomainId( "Y" ) );
4020 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4023 cd = cdcc.get( new DomainId( "Z" ) );
4024 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4027 cd = cdcc.get( new DomainId( "NN" ) );
4028 if ( cd.getKeyDomainCount() != 1 ) {
4031 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4034 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4037 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
4040 cd = cdcc.get( new DomainId( "MM" ) );
4041 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4044 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 0 ) {
4047 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
4050 cd = cdcc.get( new DomainId( "OO" ) );
4051 if ( cd.getNumberOfCombinableDomains() != 2 ) {
4054 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
4057 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 1 ) {
4060 cd = cdcc.get( new DomainId( "QQ" ) );
4061 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4064 if ( cd.getKeyDomainCount() != 17 ) {
4067 if ( cd.getKeyDomainProteinsCount() != 4 ) {
4070 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "QQ" ).getDomainId() ) != 3 ) {
4073 cd = cdcc.get( new DomainId( "PP" ) );
4074 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4077 if ( cd.getKeyDomainCount() != 2 ) {
4080 if ( cd.getKeyDomainProteinsCount() != 2 ) {
4083 cd = cdcc.get( new DomainId( "singlet" ) );
4084 if ( cd.getKeyDomainCount() != 1 ) {
4087 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4090 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4093 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "singlet" ).getDomainId() ) != 0 ) {
4096 cd = cdcc.get( new DomainId( "three" ) );
4097 if ( cd.getKeyDomainCount() != 3 ) {
4100 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4103 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4106 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 1 ) {
4109 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
4112 // Ignore combinations with same:
4113 final BasicGenomeWideCombinableDomains cdcc2 = BasicGenomeWideCombinableDomains
4114 .createInstance( domain_collections,
4116 new BasicSpecies( "human" ),
4118 DomainCombinationType.BASIC,
4121 cd = cdcc2.get( new DomainId( "A" ) );
4122 if ( cd.getKeyDomainCount() != 9 ) {
4125 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4128 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4131 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 0 ) {
4134 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
4137 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
4140 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
4143 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
4146 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4149 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4152 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4155 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
4158 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
4161 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
4164 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4167 cd = cdcc2.get( new DomainId( "B" ) );
4168 if ( cd.getKeyDomainCount() != 12 ) {
4171 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4174 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4177 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 6 ) {
4180 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 0 ) {
4183 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 4 ) {
4186 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
4189 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
4192 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4195 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4198 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4201 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
4204 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
4207 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
4210 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4213 cd = cdcc2.get( new DomainId( "C" ) );
4214 if ( cd.getKeyDomainCount() != 10 ) {
4217 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4220 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4223 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 4 ) {
4226 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 4 ) {
4229 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 0 ) {
4232 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
4235 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
4238 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4241 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4244 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4247 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 2 ) {
4250 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 2 ) {
4253 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 2 ) {
4256 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4259 cd = cdcc2.get( new DomainId( "D" ) );
4260 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4263 cd = cdcc2.get( new DomainId( "E" ) );
4264 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4267 if ( cd.getKeyDomainCount() != 1 ) {
4270 cd = cdcc2.get( new DomainId( "U" ) );
4271 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4274 cd = cdcc2.get( new DomainId( "V" ) );
4275 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4278 cd = cdcc2.get( new DomainId( "W" ) );
4279 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4282 cd = cdcc2.get( new DomainId( "X" ) );
4283 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4286 cd = cdcc2.get( new DomainId( "Y" ) );
4287 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4290 cd = cdcc2.get( new DomainId( "Z" ) );
4291 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4294 cd = cdcc2.get( new DomainId( "NN" ) );
4295 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4298 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4301 cd = cdcc2.get( new DomainId( "MM" ) );
4302 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4305 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 0 ) {
4308 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 1 ) {
4311 cd = cdcc2.get( new DomainId( "OO" ) );
4312 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4315 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 0 ) {
4318 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 1 ) {
4321 cd = cdcc2.get( new DomainId( "QQ" ) );
4322 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4325 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "QQ" ) ) != 0 ) {
4328 cd = cdcc2.get( new DomainId( "singlet" ) );
4329 if ( cd.getKeyDomainCount() != 1 ) {
4332 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4335 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4338 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "singlet" ) ) != 0 ) {
4341 cd = cdcc2.get( new DomainId( "three" ) );
4342 if ( cd.getKeyDomainCount() != 3 ) {
4345 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4348 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4351 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 0 ) {
4354 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
4358 catch ( final Exception e ) {
4359 e.printStackTrace( System.out );
4365 private static boolean testDomainId() {
4367 final DomainId id1 = new DomainId( "a" );
4368 final DomainId id2 = new DomainId( "a" );
4369 final DomainId id3 = new DomainId( "A" );
4370 final DomainId id4 = new DomainId( "b" );
4371 if ( !id1.equals( id1 ) ) {
4374 if ( id1.getId().equals( "x" ) ) {
4377 if ( id1.getId().equals( null ) ) {
4380 if ( !id1.equals( id2 ) ) {
4383 if ( id1.equals( id3 ) ) {
4386 if ( id1.hashCode() != id1.hashCode() ) {
4389 if ( id1.hashCode() != id2.hashCode() ) {
4392 if ( id1.hashCode() == id3.hashCode() ) {
4395 if ( id1.compareTo( id1 ) != 0 ) {
4398 if ( id1.compareTo( id2 ) != 0 ) {
4401 if ( id1.compareTo( id3 ) != 0 ) {
4404 if ( id1.compareTo( id4 ) >= 0 ) {
4407 if ( id4.compareTo( id1 ) <= 0 ) {
4410 if ( !id4.getId().equals( "b" ) ) {
4413 final DomainId id5 = new DomainId( " C " );
4414 if ( !id5.getId().equals( "C" ) ) {
4417 if ( id5.equals( id1 ) ) {
4421 catch ( final Exception e ) {
4422 e.printStackTrace( System.out );
4428 private static boolean testDomainSorting() {
4430 final Domain A = new BasicDomain( "A", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4431 final Domain B = new BasicDomain( "B", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4432 final Domain C = new BasicDomain( "C", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.2, -12 );
4433 final Domain D = new BasicDomain( "D", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.3, -12 );
4434 final Domain E = new BasicDomain( "E", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.4, -12 );
4435 final Domain F = new BasicDomain( "F", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.5, -12 );
4436 final Domain G = new BasicDomain( "G", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.6, -12 );
4437 final Domain H1 = new BasicDomain( "H", ( short ) 100, ( short ) 200, ( short ) 1, ( short ) 5, 0.7, -12 );
4438 final Domain H2 = new BasicDomain( "H", ( short ) 300, ( short ) 400, ( short ) 2, ( short ) 5, 0.7, -12 );
4439 final Domain H3 = new BasicDomain( "H", ( short ) 500, ( short ) 600, ( short ) 3, ( short ) 5, 0.7, -12 );
4440 final Domain H4 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 4, ( short ) 5, 0.7, -12 );
4441 final Domain H5 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4442 final Domain H6 = new BasicDomain( "H",
4449 final Domain H7 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4450 final Domain H8 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 200, 0.7, -12 );
4451 final Protein protein = new BasicProtein( "00", "bat", 0 );
4452 protein.addProteinDomain( H5 );
4453 protein.addProteinDomain( H2 );
4454 protein.addProteinDomain( H7 );
4455 protein.addProteinDomain( H6 );
4456 protein.addProteinDomain( A );
4457 protein.addProteinDomain( G );
4458 protein.addProteinDomain( H4 );
4459 protein.addProteinDomain( D );
4460 protein.addProteinDomain( H1 );
4461 protein.addProteinDomain( C );
4462 protein.addProteinDomain( E );
4463 protein.addProteinDomain( F );
4464 protein.addProteinDomain( B );
4465 protein.addProteinDomain( H3 );
4466 protein.addProteinDomain( H7 );
4467 protein.addProteinDomain( H7 );
4468 protein.addProteinDomain( H8 );
4469 final List<Domain> sorted = SurfacingUtil.sortDomainsWithAscendingConfidenceValues( protein );
4470 if ( sorted.size() != 17 ) {
4473 if ( !sorted.get( 0 ).getDomainId().getId().equals( "A" ) ) {
4476 if ( sorted.get( 0 ).getNumber() != 1 ) {
4479 if ( !sorted.get( 1 ).getDomainId().getId().equals( "B" ) ) {
4482 if ( sorted.get( 1 ).getNumber() != 1 ) {
4485 if ( !sorted.get( 2 ).getDomainId().getId().equals( "C" ) ) {
4488 if ( sorted.get( 2 ).getNumber() != 1 ) {
4491 if ( !sorted.get( 3 ).getDomainId().getId().equals( "D" ) ) {
4494 if ( sorted.get( 3 ).getNumber() != 1 ) {
4497 if ( !sorted.get( 4 ).getDomainId().getId().equals( "E" ) ) {
4500 if ( sorted.get( 4 ).getNumber() != 1 ) {
4503 if ( !sorted.get( 5 ).getDomainId().getId().equals( "F" ) ) {
4506 if ( sorted.get( 5 ).getNumber() != 1 ) {
4509 if ( !sorted.get( 6 ).getDomainId().getId().equals( "G" ) ) {
4512 if ( sorted.get( 6 ).getNumber() != 1 ) {
4515 if ( !sorted.get( 7 ).getDomainId().getId().equals( "H" ) ) {
4518 if ( sorted.get( 7 ).getNumber() != 5 ) {
4521 if ( !sorted.get( 8 ).getDomainId().getId().equals( "H" ) ) {
4524 if ( sorted.get( 8 ).getNumber() != 2 ) {
4527 if ( !sorted.get( 9 ).getDomainId().getId().equals( "H" ) ) {
4530 if ( sorted.get( 9 ).getNumber() != 6 ) {
4533 if ( !sorted.get( 10 ).getDomainId().getId().equals( "H" ) ) {
4536 if ( sorted.get( 10 ).getNumber() != 4 ) {
4539 if ( !sorted.get( 11 ).getDomainId().getId().equals( "H" ) ) {
4542 if ( sorted.get( 11 ).getNumber() != 1 ) {
4545 if ( sorted.get( 11 ).getTotalCount() != 5 ) {
4548 if ( !sorted.get( 12 ).getDomainId().getId().equals( "H" ) ) {
4551 if ( sorted.get( 12 ).getNumber() != 3 ) {
4554 if ( !sorted.get( 13 ).getDomainId().getId().equals( "H7" ) ) {
4557 if ( sorted.get( 13 ).getNumber() != 5 ) {
4560 if ( !sorted.get( 14 ).getDomainId().getId().equals( "H7" ) ) {
4563 if ( sorted.get( 14 ).getNumber() != 5 ) {
4566 if ( !sorted.get( 15 ).getDomainId().getId().equals( "H7" ) ) {
4569 if ( sorted.get( 15 ).getNumber() != 5 ) {
4572 // To check if sorting is stable [as claimed by Sun for
4573 // Collections.sort( List )]
4574 if ( !sorted.get( 16 ).getDomainId().getId().equals( "H7" ) ) {
4577 if ( sorted.get( 16 ).getNumber() != 5 ) {
4580 if ( sorted.get( 16 ).getTotalCount() != 200 ) {
4584 catch ( final Exception e ) {
4585 e.printStackTrace( System.out );
4591 private static boolean testEngulfingOverlapRemoval() {
4593 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4594 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
4595 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
4596 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4597 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4598 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4599 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
4600 final List<Boolean> covered = new ArrayList<Boolean>();
4601 covered.add( true ); // 0
4602 covered.add( false ); // 1
4603 covered.add( true ); // 2
4604 covered.add( false ); // 3
4605 covered.add( true ); // 4
4606 covered.add( true ); // 5
4607 covered.add( false ); // 6
4608 covered.add( true ); // 7
4609 covered.add( true ); // 8
4610 if ( SurfacingUtil.isEngulfed( d0, covered ) ) {
4613 if ( SurfacingUtil.isEngulfed( d1, covered ) ) {
4616 if ( SurfacingUtil.isEngulfed( d2, covered ) ) {
4619 if ( !SurfacingUtil.isEngulfed( d3, covered ) ) {
4622 if ( SurfacingUtil.isEngulfed( d4, covered ) ) {
4625 if ( SurfacingUtil.isEngulfed( d5, covered ) ) {
4628 if ( !SurfacingUtil.isEngulfed( d6, covered ) ) {
4631 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4632 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
4633 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
4634 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
4635 abc.addProteinDomain( a );
4636 abc.addProteinDomain( b );
4637 abc.addProteinDomain( c );
4638 final Protein abc_r1 = SurfacingUtil.removeOverlappingDomains( 3, false, abc );
4639 final Protein abc_r2 = SurfacingUtil.removeOverlappingDomains( 3, true, abc );
4640 if ( abc.getNumberOfProteinDomains() != 3 ) {
4643 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
4646 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
4649 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
4652 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "b" ) ) {
4655 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4656 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
4657 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
4658 final Protein def = new BasicProtein( "def", "nemve", 0 );
4659 def.addProteinDomain( d );
4660 def.addProteinDomain( e );
4661 def.addProteinDomain( f );
4662 final Protein def_r1 = SurfacingUtil.removeOverlappingDomains( 5, false, def );
4663 final Protein def_r2 = SurfacingUtil.removeOverlappingDomains( 5, true, def );
4664 if ( def.getNumberOfProteinDomains() != 3 ) {
4667 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
4670 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
4673 if ( !def_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "d" ) ) {
4676 if ( !def_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "f" ) ) {
4679 if ( !def_r2.getProteinDomain( 2 ).getDomainId().getId().equals( "e" ) ) {
4683 catch ( final Exception e ) {
4684 e.printStackTrace( System.out );
4690 private static boolean testGenomeWideCombinableDomains() {
4692 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4693 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4694 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4695 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4696 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4697 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4698 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4699 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4700 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4701 final Protein eel_0 = new BasicProtein( "0", "eel", 0 );
4702 final Protein eel_1 = new BasicProtein( "1", "eel", 0 );
4703 final Protein eel_2 = new BasicProtein( "2", "eel", 0 );
4704 final Protein eel_3 = new BasicProtein( "3", "eel", 0 );
4705 final Protein eel_4 = new BasicProtein( "4", "eel", 0 );
4706 final Protein eel_5 = new BasicProtein( "5", "eel", 0 );
4707 final Protein eel_6 = new BasicProtein( "6", "eel", 0 );
4708 eel_1.addProteinDomain( a );
4709 eel_2.addProteinDomain( a );
4710 eel_2.addProteinDomain( b );
4711 eel_3.addProteinDomain( a );
4712 eel_3.addProteinDomain( a );
4713 eel_3.addProteinDomain( b );
4714 eel_4.addProteinDomain( a );
4715 eel_4.addProteinDomain( b );
4716 eel_4.addProteinDomain( c );
4717 eel_4.addProteinDomain( d );
4718 eel_4.addProteinDomain( e );
4719 eel_5.addProteinDomain( e );
4720 eel_5.addProteinDomain( e );
4721 eel_5.addProteinDomain( f );
4722 eel_5.addProteinDomain( f );
4723 eel_5.addProteinDomain( f );
4724 eel_5.addProteinDomain( f );
4725 eel_6.addProteinDomain( g );
4726 eel_6.addProteinDomain( h );
4727 final List<Protein> protein_list_eel = new ArrayList<Protein>();
4728 protein_list_eel.add( eel_0 );
4729 protein_list_eel.add( eel_1 );
4730 protein_list_eel.add( eel_2 );
4731 protein_list_eel.add( eel_3 );
4732 protein_list_eel.add( eel_4 );
4733 protein_list_eel.add( eel_5 );
4734 protein_list_eel.add( eel_6 );
4735 final BasicGenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
4736 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
4737 final BasicGenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
4738 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
4739 if ( !eel_not_ignore.contains( new DomainId( "a" ) ) ) {
4742 if ( !eel_not_ignore.contains( new DomainId( "b" ) ) ) {
4745 if ( !eel_not_ignore.contains( new DomainId( "c" ) ) ) {
4748 if ( !eel_not_ignore.contains( new DomainId( "d" ) ) ) {
4751 if ( !eel_not_ignore.contains( new DomainId( "e" ) ) ) {
4754 if ( !eel_not_ignore.contains( new DomainId( "f" ) ) ) {
4757 if ( !eel_not_ignore.contains( new DomainId( "g" ) ) ) {
4760 if ( !eel_not_ignore.contains( new DomainId( "h" ) ) ) {
4763 if ( eel_not_ignore.contains( new DomainId( "x" ) ) ) {
4766 if ( !eel_ignore.contains( new DomainId( "a" ) ) ) {
4769 if ( !eel_ignore.contains( new DomainId( "b" ) ) ) {
4772 if ( !eel_ignore.contains( new DomainId( "c" ) ) ) {
4775 if ( !eel_ignore.contains( new DomainId( "d" ) ) ) {
4778 if ( !eel_ignore.contains( new DomainId( "e" ) ) ) {
4781 if ( !eel_ignore.contains( new DomainId( "f" ) ) ) {
4784 if ( !eel_ignore.contains( new DomainId( "g" ) ) ) {
4787 if ( !eel_ignore.contains( new DomainId( "h" ) ) ) {
4790 if ( eel_ignore.contains( new DomainId( "x" ) ) ) {
4793 if ( eel_not_ignore.getSize() != 8 ) {
4796 if ( eel_ignore.getSize() != 8 ) {
4799 if ( eel_not_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 5 ) {
4802 if ( eel_not_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4805 if ( eel_not_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4808 if ( eel_not_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4811 if ( eel_not_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 6 ) {
4814 if ( eel_not_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 2 ) {
4817 if ( eel_not_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4820 if ( eel_not_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4823 if ( eel_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 4 ) {
4826 if ( eel_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4829 if ( eel_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4832 if ( eel_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4835 if ( eel_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 5 ) {
4838 if ( eel_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 1 ) {
4841 if ( eel_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4844 if ( eel_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4847 if ( eel_not_ignore.getAllDomainIds().size() != 8 ) {
4850 if ( !eel_not_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4853 if ( !eel_not_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4856 if ( !eel_not_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4859 if ( !eel_not_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4862 if ( !eel_not_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4865 if ( !eel_not_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4868 if ( !eel_not_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4871 if ( !eel_not_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4874 if ( eel_not_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4877 if ( eel_ignore.getAllDomainIds().size() != 8 ) {
4880 if ( !eel_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4883 if ( !eel_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4886 if ( !eel_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4889 if ( !eel_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4892 if ( !eel_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4895 if ( !eel_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4898 if ( !eel_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4901 if ( !eel_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4904 if ( eel_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4907 final SortedSet<BinaryDomainCombination> bc0 = eel_not_ignore.toBinaryDomainCombinations();
4908 if ( bc0.size() != 15 ) {
4911 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4914 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4917 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4920 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4923 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4926 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4929 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4932 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4935 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4938 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4941 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
4944 if ( !bc0.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
4947 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
4950 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
4953 if ( !bc0.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
4956 if ( !bc0.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
4959 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
4962 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
4965 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "h" ) ) ) {
4968 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
4971 final SortedSet<BinaryDomainCombination> bc1 = eel_ignore.toBinaryDomainCombinations();
4972 if ( bc1.size() != 12 ) {
4975 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4978 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4981 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4984 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4987 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4990 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4993 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4996 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4999 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
5002 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
5005 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
5008 if ( !bc1.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
5011 if ( !bc1.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
5014 if ( !bc1.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
5017 if ( bc1.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
5020 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
5023 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
5026 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
5029 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
5032 if ( bc1.contains( new BasicBinaryDomainCombination( "b", "g" ) ) ) {
5036 catch ( final Exception e ) {
5037 e.printStackTrace( System.out );
5043 private static boolean testHmmPfamOutputParser( final File test_dir ) {
5045 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
5046 + ForesterUtil.getFileSeparator() + "hmmpfam_output" ), "human", "ls" );
5047 parser.setEValueMaximum( 0.2 );
5048 parser.setIgnoreDufs( true );
5049 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5050 List<?> domain_collections = null;
5051 domain_collections = parser.parse();
5052 if ( parser.getDomainsEncountered() != 4 ) {
5055 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
5058 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
5061 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
5064 if ( parser.getDomainsStored() != 3 ) {
5067 if ( domain_collections.size() != 1 ) {
5070 final Protein pdc = ( Protein ) domain_collections.get( 0 );
5071 if ( !pdc.getProteinId().equals( new ProteinId( "ENSP00000285681" ) ) ) {
5074 if ( !pdc.getSpecies().getSpeciesId().equals( "human" ) ) {
5077 if ( pdc.getNumberOfProteinDomains() != 3 ) {
5080 if ( !pdc.getAccession().equals( "acc_ENSP00000285681" ) ) {
5085 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
5088 final List<Domain> uba = pdc.getProteinDomains( new DomainId( "UBA" ) );
5089 final List<Domain> uim = pdc.getProteinDomains( new DomainId( "UIM" ) );
5090 final List<Domain> uch = pdc.getProteinDomains( new DomainId( "UCH" ) );
5091 if ( uba.size() != 1 ) {
5094 if ( uim.size() != 2 ) {
5097 if ( uch.size() != 0 ) {
5100 final BasicDomain uim_domain = ( BasicDomain ) uim.get( 1 );
5101 if ( !uim_domain.getDomainId().equals( new DomainId( "UIM" ) ) ) {
5104 if ( uim_domain.getTotalCount() != 2 ) {
5107 final BasicDomain uba_domain = ( BasicDomain ) uba.get( 0 );
5108 if ( !uba_domain.getDomainId().equals( new DomainId( "UBA" ) ) ) {
5111 if ( uba_domain.getNumber() != 1 ) {
5114 if ( uba_domain.getTotalCount() != 1 ) {
5117 if ( uba_domain.getFrom() != 16 ) {
5120 if ( uba_domain.getTo() != 57 ) {
5123 if ( !Test.isEqual( uba_domain.getPerSequenceEvalue(), 0.00084 ) ) {
5126 if ( !Test.isEqual( uba_domain.getPerSequenceScore(), 23.2 ) ) {
5129 final HmmPfamOutputParser parser2 = new HmmPfamOutputParser( new File( test_dir
5130 + ForesterUtil.getFileSeparator() + "hmmpfam_output_short" ), "human", "ls" );
5131 parser2.setEValueMaximum( 0.2 );
5132 parser2.setIgnoreDufs( true );
5133 parser2.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5134 List<Protein> domain_collections2 = null;
5135 domain_collections2 = parser2.parse();
5136 if ( parser2.getDomainsEncountered() != 4 ) {
5139 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
5142 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
5145 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
5148 if ( parser2.getDomainsStored() != 3 ) {
5151 if ( domain_collections2.size() != 1 ) {
5154 final Protein pdc2 = domain_collections2.get( 0 );
5155 if ( !pdc2.getProteinId().getId().equals( "ENSP00000285681" ) ) {
5158 if ( !pdc2.getSpecies().getSpeciesId().equals( "human" ) ) {
5161 if ( !pdc2.getName().equals( "" ) ) {
5164 if ( !pdc2.getAccession().equals( "223" ) ) {
5169 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
5172 if ( pdc2.getNumberOfProteinDomains() != 3 ) {
5175 final List<Domain> uba2 = pdc2.getProteinDomains( new DomainId( "UBA" ) );
5176 final List<Domain> uim2 = pdc2.getProteinDomains( new DomainId( "UIM" ) );
5177 final List<Domain> uch2 = pdc2.getProteinDomains( new DomainId( "UCH" ) );
5178 if ( uba2.size() != 1 ) {
5181 if ( uim2.size() != 2 ) {
5184 if ( uch2.size() != 0 ) {
5187 final BasicDomain uim_domain2 = ( BasicDomain ) uim2.get( 1 );
5188 if ( !uim_domain2.getDomainId().getId().equals( "UIM" ) ) {
5191 if ( uim_domain2.getTotalCount() != 2 ) {
5194 final BasicDomain uba_domain2 = ( BasicDomain ) uba2.get( 0 );
5195 if ( !uba_domain2.getDomainId().getId().equals( "UBA" ) ) {
5198 if ( uba_domain2.getNumber() != 1 ) {
5201 if ( uba_domain2.getTotalCount() != 1 ) {
5204 if ( uba_domain2.getFrom() != 16 ) {
5207 if ( uba_domain2.getTo() != 57 ) {
5210 if ( !Test.isEqual( uba_domain2.getPerSequenceEvalue(), 0.00084 ) ) {
5214 catch ( final Exception e ) {
5215 e.printStackTrace( System.out );
5221 private static boolean testHmmPfamOutputParserWithFilter( final File test_dir ) {
5223 HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator()
5224 + "hmmpfam_output3" ), "human", "ls" );
5225 parser.setEValueMaximum( 0.2 );
5226 parser.setIgnoreDufs( true );
5227 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5228 List<Protein> proteins = null;
5229 proteins = parser.parse();
5230 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5233 if ( proteins.size() != 4 ) {
5237 Set<DomainId> filter = new TreeSet<DomainId>();
5238 filter.add( new DomainId( "beauty" ) );
5239 filter.add( new DomainId( "strange" ) );
5240 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5244 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5245 parser.setEValueMaximum( 0.2 );
5246 parser.setIgnoreDufs( true );
5247 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5249 proteins = parser.parse();
5250 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5253 if ( proteins.size() != 4 ) {
5257 filter = new TreeSet<DomainId>();
5258 filter.add( new DomainId( "beauty" ) );
5259 filter.add( new DomainId( "strange" ) );
5260 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5264 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5265 parser.setEValueMaximum( 0.2 );
5266 parser.setIgnoreDufs( true );
5267 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5269 proteins = parser.parse();
5270 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
5273 if ( proteins.size() != 0 ) {
5277 filter = new TreeSet<DomainId>();
5278 filter.add( new DomainId( "UIM" ) );
5279 filter.add( new DomainId( "A" ) );
5280 filter.add( new DomainId( "C" ) );
5281 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5285 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5286 parser.setEValueMaximum( 0.2 );
5287 parser.setIgnoreDufs( true );
5288 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5290 proteins = parser.parse();
5291 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5294 if ( proteins.size() != 4 ) {
5298 filter = new TreeSet<DomainId>();
5299 filter.add( new DomainId( "UIM" ) );
5300 filter.add( new DomainId( "A" ) );
5301 filter.add( new DomainId( "C" ) );
5302 filter.add( new DomainId( "X" ) );
5303 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5307 HmmPfamOutputParser.FilterType.NEGATIVE_DOMAIN );
5308 parser.setEValueMaximum( 0.2 );
5309 parser.setIgnoreDufs( true );
5310 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5312 proteins = parser.parse();
5313 if ( parser.getDomainsIgnoredDueToNegativeDomainFilter() != 7 ) {
5316 if ( proteins.size() != 3 ) {
5320 filter = new TreeSet<DomainId>();
5321 filter.add( new DomainId( "UIM" ) );
5322 filter.add( new DomainId( "A" ) );
5323 filter.add( new DomainId( "C" ) );
5324 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5328 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5329 parser.setEValueMaximum( 0.2 );
5330 parser.setIgnoreDufs( true );
5331 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5333 proteins = parser.parse();
5334 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
5337 if ( proteins.size() != 0 ) {
5341 filter = new TreeSet<DomainId>();
5342 filter.add( new DomainId( "UIM" ) );
5343 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5347 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5348 parser.setEValueMaximum( 0.2 );
5349 parser.setIgnoreDufs( true );
5350 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5352 proteins = parser.parse();
5353 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
5356 if ( parser.getProteinsStored() != 3 ) {
5359 if ( proteins.size() != 3 ) {
5363 filter = new TreeSet<DomainId>();
5364 filter.add( new DomainId( "UIM" ) );
5365 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5369 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5370 parser.setEValueMaximum( 0.2 );
5371 parser.setIgnoreDufs( true );
5372 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5374 proteins = parser.parse();
5375 if ( parser.getProteinsIgnoredDueToFilter() != 3 ) {
5378 if ( parser.getProteinsStored() != 1 ) {
5381 if ( proteins.size() != 1 ) {
5385 filter = new TreeSet<DomainId>();
5386 filter.add( new DomainId( "A" ) );
5387 filter.add( new DomainId( "C" ) );
5388 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5392 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5393 parser.setEValueMaximum( 0.2 );
5394 parser.setIgnoreDufs( true );
5395 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5397 proteins = parser.parse();
5398 if ( parser.getDomainsEncountered() != 11 ) {
5401 if ( parser.getProteinsEncountered() != 4 ) {
5404 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
5407 if ( parser.getProteinsStored() != 3 ) {
5410 if ( proteins.size() != 3 ) {
5414 catch ( final Exception e ) {
5415 e.printStackTrace( System.out );
5421 private static boolean testOverlapRemoval() {
5423 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
5424 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5425 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
5426 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5427 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
5428 final List<Boolean> covered = new ArrayList<Boolean>();
5429 covered.add( true ); // 0
5430 covered.add( false ); // 1
5431 covered.add( true ); // 2
5432 covered.add( false ); // 3
5433 covered.add( true ); // 4
5434 covered.add( true ); // 5
5435 covered.add( false ); // 6
5436 covered.add( true ); // 7
5437 covered.add( true ); // 8
5438 if ( SurfacingUtil.calculateOverlap( d0, covered ) != 3 ) {
5441 if ( SurfacingUtil.calculateOverlap( d1, covered ) != 2 ) {
5444 if ( SurfacingUtil.calculateOverlap( d2, covered ) != 6 ) {
5447 if ( SurfacingUtil.calculateOverlap( d3, covered ) != 0 ) {
5450 if ( SurfacingUtil.calculateOverlap( d4, covered ) != 2 ) {
5453 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.01, 1 );
5454 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5455 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
5456 ab.addProteinDomain( a );
5457 ab.addProteinDomain( b );
5458 final Protein ab_s0 = SurfacingUtil.removeOverlappingDomains( 3, false, ab );
5459 if ( ab.getNumberOfProteinDomains() != 2 ) {
5462 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
5465 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
5468 final Protein ab_s1 = SurfacingUtil.removeOverlappingDomains( 4, false, ab );
5469 if ( ab.getNumberOfProteinDomains() != 2 ) {
5472 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
5475 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
5476 final Domain d = new BasicDomain( "d",
5483 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
5484 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
5485 cde.addProteinDomain( c );
5486 cde.addProteinDomain( d );
5487 cde.addProteinDomain( e );
5488 final Protein cde_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, cde );
5489 if ( cde.getNumberOfProteinDomains() != 3 ) {
5492 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
5495 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5496 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5497 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5498 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
5499 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
5500 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
5501 fghi.addProteinDomain( f );
5502 fghi.addProteinDomain( g );
5503 fghi.addProteinDomain( h );
5504 fghi.addProteinDomain( i );
5505 fghi.addProteinDomain( i );
5506 fghi.addProteinDomain( i );
5507 fghi.addProteinDomain( i2 );
5508 final Protein fghi_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, fghi );
5509 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5512 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
5515 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "h" ) ) {
5518 final Protein fghi_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, fghi );
5519 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5522 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
5525 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5526 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5527 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5528 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
5529 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
5530 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
5531 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5532 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
5533 jklm.addProteinDomain( j );
5534 jklm.addProteinDomain( k );
5535 jklm.addProteinDomain( l );
5536 jklm.addProteinDomain( m );
5537 jklm.addProteinDomain( m0 );
5538 jklm.addProteinDomain( m1 );
5539 jklm.addProteinDomain( m2 );
5540 final Protein jklm_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, jklm );
5541 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5544 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
5547 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "l" ) ) {
5550 final Protein jklm_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, jklm );
5551 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5554 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
5557 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5558 final Protein od = new BasicProtein( "od", "varanus", 0 );
5559 od.addProteinDomain( only );
5560 final Protein od_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, od );
5561 if ( od.getNumberOfProteinDomains() != 1 ) {
5564 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
5568 catch ( final Exception e ) {
5569 e.printStackTrace( System.out );
5575 private static boolean testParsimony() {
5577 final BinaryStates X = BinaryStates.PRESENT;
5578 final BinaryStates O = BinaryStates.ABSENT;
5579 final GainLossStates G = GainLossStates.GAIN;
5580 final GainLossStates L = GainLossStates.LOSS;
5581 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5582 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5583 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5584 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5585 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5586 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5587 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5588 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5589 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5590 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5591 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5592 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5593 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5594 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5595 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5596 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5597 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5598 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5599 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5600 // 1 a-a a-b a-c e-f-g-h l-m
5601 // 2 a-b a-c e-f-g-i n-o
5602 // 3 a-b a-d e-f-g-j p-q
5604 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5605 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5606 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5608 // 1 a b c e f g h l m
5609 // 2 a b c e f g i n o
5610 // 3 a b d e f g j p q
5612 final Protein aa1 = new BasicProtein( "aa1", "one", 0 );
5613 aa1.addProteinDomain( a );
5614 aa1.addProteinDomain( a );
5615 final Protein ab1 = new BasicProtein( "ab1", "one", 0 );
5616 ab1.addProteinDomain( a );
5617 ab1.addProteinDomain( b );
5618 final Protein ac1 = new BasicProtein( "ac1", "one", 0 );
5619 ac1.addProteinDomain( a );
5620 ac1.addProteinDomain( c );
5621 final Protein efgh1 = new BasicProtein( "efgh1", "one", 0 );
5622 efgh1.addProteinDomain( e );
5623 efgh1.addProteinDomain( f );
5624 efgh1.addProteinDomain( g );
5625 efgh1.addProteinDomain( h );
5626 final Protein lm1 = new BasicProtein( "lm1", "one", 0 );
5627 lm1.addProteinDomain( l );
5628 lm1.addProteinDomain( m );
5629 final Protein ab2 = new BasicProtein( "ab2", "two", 0 );
5630 ab2.addProteinDomain( a );
5631 ab2.addProteinDomain( b );
5632 final Protein ac2 = new BasicProtein( "ac2", "two", 0 );
5633 ac2.addProteinDomain( a );
5634 ac2.addProteinDomain( c );
5635 final Protein efgi2 = new BasicProtein( "efgi2", "two", 0 );
5636 efgi2.addProteinDomain( e );
5637 efgi2.addProteinDomain( f );
5638 efgi2.addProteinDomain( g );
5639 efgi2.addProteinDomain( i );
5640 final Protein no2 = new BasicProtein( "no2", "two", 0 );
5641 no2.addProteinDomain( n );
5642 no2.addProteinDomain( o );
5643 final Protein ab3 = new BasicProtein( "ab3", "three", 0 );
5644 ab3.addProteinDomain( a );
5645 ab3.addProteinDomain( b );
5646 final Protein ad3 = new BasicProtein( "ad3", "three", 0 );
5647 ad3.addProteinDomain( a );
5648 ad3.addProteinDomain( d );
5649 final Protein efgj3 = new BasicProtein( "efgj3", "three", 0 );
5650 efgj3.addProteinDomain( e );
5651 efgj3.addProteinDomain( f );
5652 efgj3.addProteinDomain( g );
5653 efgj3.addProteinDomain( j );
5654 final Protein pq3 = new BasicProtein( "pq3", "three", 0 );
5655 pq3.addProteinDomain( p );
5656 pq3.addProteinDomain( q );
5657 final Protein ab4 = new BasicProtein( "ab4", "four", 0 );
5658 ab4.addProteinDomain( a );
5659 ab4.addProteinDomain( b );
5660 final Protein ad4 = new BasicProtein( "ad4", "four", 0 );
5661 ad4.addProteinDomain( a );
5662 ad4.addProteinDomain( d );
5663 final Protein pr4 = new BasicProtein( "pr4", "four", 0 );
5664 pr4.addProteinDomain( p );
5665 pr4.addProteinDomain( r );
5666 final List<Protein> one_list = new ArrayList<Protein>();
5667 one_list.add( aa1 );
5668 one_list.add( ab1 );
5669 one_list.add( ac1 );
5670 one_list.add( efgh1 );
5671 one_list.add( lm1 );
5672 final List<Protein> two_list = new ArrayList<Protein>();
5673 two_list.add( ab2 );
5674 two_list.add( ac2 );
5675 two_list.add( efgi2 );
5676 two_list.add( no2 );
5677 final List<Protein> three_list = new ArrayList<Protein>();
5678 three_list.add( ab3 );
5679 three_list.add( ad3 );
5680 three_list.add( efgj3 );
5681 three_list.add( pq3 );
5682 final List<Protein> four_list = new ArrayList<Protein>();
5683 four_list.add( ab4 );
5684 four_list.add( ad4 );
5685 four_list.add( pr4 );
5686 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5687 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5688 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5689 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5690 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5691 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5692 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5693 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5694 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5695 gwcd_list.add( one );
5696 gwcd_list.add( two );
5697 gwcd_list.add( three );
5698 gwcd_list.add( four );
5699 final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
5700 .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
5701 final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
5702 .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
5703 // 1 a b c e f g h l m
5704 // 2 a b c e f g i n o
5705 // 3 a b d e f g j p q
5707 if ( matrix_d.getState( 0, 0 ) != X ) {
5710 if ( matrix_d.getState( 0, 1 ) != X ) {
5713 if ( matrix_d.getState( 0, 2 ) != X ) {
5716 if ( matrix_d.getState( 0, 3 ) != O ) {
5719 if ( matrix_d.getState( 0, 4 ) != X ) {
5722 if ( matrix_d.getState( 0, 5 ) != X ) {
5725 if ( matrix_d.getState( 0, 6 ) != X ) {
5728 if ( matrix_d.getState( 0, 7 ) != X ) {
5731 if ( matrix_d.getState( 0, 8 ) != O ) {
5734 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5735 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5736 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5738 if ( matrix_bc.getState( 0, 0 ) != X ) {
5741 if ( matrix_bc.getState( 0, 1 ) != X ) {
5744 if ( matrix_bc.getState( 0, 2 ) != X ) {
5747 if ( matrix_bc.getState( 0, 3 ) != O ) {
5750 if ( matrix_bc.getState( 0, 4 ) != X ) {
5753 if ( matrix_bc.getState( 1, 0 ) != O ) {
5756 if ( matrix_bc.getState( 1, 1 ) != X ) {
5759 if ( matrix_bc.getState( 1, 2 ) != X ) {
5762 if ( matrix_bc.getState( 1, 3 ) != O ) {
5765 if ( matrix_bc.getState( 1, 4 ) != X ) {
5768 if ( matrix_bc.getState( 2, 0 ) != O ) {
5771 if ( matrix_bc.getState( 2, 1 ) != X ) {
5774 if ( matrix_bc.getState( 2, 2 ) != O ) {
5777 if ( matrix_bc.getState( 2, 3 ) != X ) {
5780 if ( matrix_bc.getState( 2, 4 ) != X ) {
5783 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
5784 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
5785 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
5786 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list );
5787 dp0.executeDolloParsimonyOnDomainPresence();
5788 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
5789 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
5790 dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
5791 final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
5792 final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
5793 if ( is_matrix_d.getState( "root", "A" ) != X ) {
5796 if ( is_matrix_d.getState( "root", "B" ) != X ) {
5799 if ( is_matrix_d.getState( "root", "C" ) != O ) {
5802 if ( is_matrix_d.getState( "root", "D" ) != O ) {
5805 if ( is_matrix_d.getState( "root", "E" ) != X ) {
5808 if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
5811 if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
5814 if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
5817 if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
5820 if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
5823 if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
5826 if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
5829 if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
5832 if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
5835 if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
5838 if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
5841 if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
5844 if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
5847 if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
5851 catch ( final Exception e ) {
5852 e.printStackTrace( System.out );
5858 private static boolean testParsimonyOnSecondaryFeatures() {
5860 final BinaryStates X = BinaryStates.PRESENT;
5861 final BinaryStates O = BinaryStates.ABSENT;
5862 final GainLossStates G = GainLossStates.GAIN;
5863 final GainLossStates L = GainLossStates.LOSS;
5864 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5865 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5866 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5867 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5868 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5869 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5870 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5871 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5872 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5873 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5874 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5875 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5876 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5877 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5878 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5879 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5880 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5881 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5882 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5883 // 1 a-a a-b a-c e-f-g-h l-m
5884 // 2 a-b a-c e-f-g-i n-o
5885 // 3 a-b a-d e-f-g-j p-q
5887 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5888 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5889 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5891 // 1 a b c e f g h l m
5892 // 2 a b c e f g i n o
5893 // 3 a b d e f g j p q
5895 final Protein aa1 = new BasicProtein( "aa1", "one", 0 );
5896 aa1.addProteinDomain( a );
5897 aa1.addProteinDomain( a );
5898 final Protein ab1 = new BasicProtein( "ab1", "one", 0 );
5899 ab1.addProteinDomain( a );
5900 ab1.addProteinDomain( b );
5901 final Protein ac1 = new BasicProtein( "ac1", "one", 0 );
5902 ac1.addProteinDomain( a );
5903 ac1.addProteinDomain( c );
5904 final Protein efgh1 = new BasicProtein( "efgh1", "one", 0 );
5905 efgh1.addProteinDomain( e );
5906 efgh1.addProteinDomain( f );
5907 efgh1.addProteinDomain( g );
5908 efgh1.addProteinDomain( h );
5909 final Protein lm1 = new BasicProtein( "lm1", "one", 0 );
5910 lm1.addProteinDomain( l );
5911 lm1.addProteinDomain( m );
5912 final Protein ab2 = new BasicProtein( "ab2", "two", 0 );
5913 ab2.addProteinDomain( a );
5914 ab2.addProteinDomain( b );
5915 final Protein ac2 = new BasicProtein( "ac2", "two", 0 );
5916 ac2.addProteinDomain( a );
5917 ac2.addProteinDomain( c );
5918 final Protein efgi2 = new BasicProtein( "efgi2", "two", 0 );
5919 efgi2.addProteinDomain( e );
5920 efgi2.addProteinDomain( f );
5921 efgi2.addProteinDomain( g );
5922 efgi2.addProteinDomain( i );
5923 final Protein no2 = new BasicProtein( "no2", "two", 0 );
5924 no2.addProteinDomain( n );
5925 no2.addProteinDomain( o );
5926 final Protein ab3 = new BasicProtein( "ab3", "three", 0 );
5927 ab3.addProteinDomain( a );
5928 ab3.addProteinDomain( b );
5929 final Protein ad3 = new BasicProtein( "ad3", "three", 0 );
5930 ad3.addProteinDomain( a );
5931 ad3.addProteinDomain( d );
5932 final Protein efgj3 = new BasicProtein( "efgj3", "three", 0 );
5933 efgj3.addProteinDomain( e );
5934 efgj3.addProteinDomain( f );
5935 efgj3.addProteinDomain( g );
5936 efgj3.addProteinDomain( j );
5937 final Protein pq3 = new BasicProtein( "pq3", "three", 0 );
5938 pq3.addProteinDomain( p );
5939 pq3.addProteinDomain( q );
5940 final Protein ab4 = new BasicProtein( "ab4", "four", 0 );
5941 ab4.addProteinDomain( a );
5942 ab4.addProteinDomain( b );
5943 final Protein ad4 = new BasicProtein( "ad4", "four", 0 );
5944 ad4.addProteinDomain( a );
5945 ad4.addProteinDomain( d );
5946 final Protein pr4 = new BasicProtein( "pr4", "four", 0 );
5947 pr4.addProteinDomain( p );
5948 pr4.addProteinDomain( r );
5949 final List<Protein> one_list = new ArrayList<Protein>();
5950 one_list.add( aa1 );
5951 one_list.add( ab1 );
5952 one_list.add( ac1 );
5953 one_list.add( efgh1 );
5954 one_list.add( lm1 );
5955 final List<Protein> two_list = new ArrayList<Protein>();
5956 two_list.add( ab2 );
5957 two_list.add( ac2 );
5958 two_list.add( efgi2 );
5959 two_list.add( no2 );
5960 final List<Protein> three_list = new ArrayList<Protein>();
5961 three_list.add( ab3 );
5962 three_list.add( ad3 );
5963 three_list.add( efgj3 );
5964 three_list.add( pq3 );
5965 final List<Protein> four_list = new ArrayList<Protein>();
5966 four_list.add( ab4 );
5967 four_list.add( ad4 );
5968 four_list.add( pr4 );
5969 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5970 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5971 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5972 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5973 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5974 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5975 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5976 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5977 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5978 gwcd_list.add( one );
5979 gwcd_list.add( two );
5980 gwcd_list.add( three );
5981 gwcd_list.add( four );
5982 final Map<DomainId, Set<String>> map_same = new HashMap<DomainId, Set<String>>();
5983 final HashSet<String> a_s = new HashSet<String>();
5985 final HashSet<String> b_s = new HashSet<String>();
5987 final HashSet<String> c_s = new HashSet<String>();
5989 final HashSet<String> d_s = new HashSet<String>();
5991 final HashSet<String> e_s = new HashSet<String>();
5993 final HashSet<String> f_s = new HashSet<String>();
5995 final HashSet<String> g_s = new HashSet<String>();
5997 final HashSet<String> h_s = new HashSet<String>();
5999 final HashSet<String> i_s = new HashSet<String>();
6001 final HashSet<String> j_s = new HashSet<String>();
6003 final HashSet<String> l_s = new HashSet<String>();
6005 final HashSet<String> m_s = new HashSet<String>();
6007 final HashSet<String> n_s = new HashSet<String>();
6009 final HashSet<String> o_s = new HashSet<String>();
6011 final HashSet<String> p_s = new HashSet<String>();
6013 final HashSet<String> q_s = new HashSet<String>();
6015 final HashSet<String> r_s = new HashSet<String>();
6017 map_same.put( a.getDomainId(), a_s );
6018 map_same.put( b.getDomainId(), b_s );
6019 map_same.put( c.getDomainId(), c_s );
6020 map_same.put( d.getDomainId(), d_s );
6021 map_same.put( e.getDomainId(), e_s );
6022 map_same.put( f.getDomainId(), f_s );
6023 map_same.put( g.getDomainId(), g_s );
6024 map_same.put( h.getDomainId(), h_s );
6025 map_same.put( i.getDomainId(), i_s );
6026 map_same.put( j.getDomainId(), j_s );
6027 map_same.put( l.getDomainId(), l_s );
6028 map_same.put( m.getDomainId(), m_s );
6029 map_same.put( n.getDomainId(), n_s );
6030 map_same.put( o.getDomainId(), o_s );
6031 map_same.put( p.getDomainId(), p_s );
6032 map_same.put( q.getDomainId(), q_s );
6033 map_same.put( r.getDomainId(), r_s );
6034 final CharacterStateMatrix<BinaryStates> matrix_s = DomainParsimonyCalculator
6035 .createMatrixOfSecondaryFeaturePresenceOrAbsence( gwcd_list, map_same, null );
6036 // 1 a b c e f g h l m
6037 // 2 a b c e f g i n o
6038 // 3 a b d e f g j p q
6040 if ( matrix_s.getState( 0, 0 ) != X ) {
6043 if ( matrix_s.getState( 0, 1 ) != X ) {
6046 if ( matrix_s.getState( 0, 2 ) != X ) {
6049 if ( matrix_s.getState( 0, 3 ) != O ) {
6052 if ( matrix_s.getState( 0, 4 ) != X ) {
6055 if ( matrix_s.getState( 0, 5 ) != X ) {
6058 if ( matrix_s.getState( 0, 6 ) != X ) {
6061 if ( matrix_s.getState( 0, 7 ) != X ) {
6064 if ( matrix_s.getState( 0, 8 ) != O ) {
6067 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
6068 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
6069 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
6070 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list, map_same );
6071 dp0.executeDolloParsimonyOnSecondaryFeatures( null );
6072 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
6073 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
6074 if ( is_matrix_d.getState( "root", "AAA" ) != X ) {
6077 if ( is_matrix_d.getState( "root", "BBB" ) != X ) {
6080 if ( is_matrix_d.getState( "root", "CCC" ) != O ) {
6083 if ( is_matrix_d.getState( "root", "DDD" ) != O ) {
6086 if ( is_matrix_d.getState( "root", "EEE" ) != X ) {
6089 if ( gl_matrix_d.getState( "3-4", "PPP" ) != G ) {
6093 catch ( final Exception e ) {
6094 e.printStackTrace( System.out );
6100 private static boolean testPaupLogParser( final File test_dir ) {
6102 final PaupLogParser parser = new PaupLogParser();
6103 parser.setSource( new File( test_dir + ForesterUtil.getFileSeparator() + "paup_log_test_1" ) );
6104 final CharacterStateMatrix<BinaryStates> matrix = parser.parse();
6105 if ( matrix.getNumberOfIdentifiers() != 8 ) {
6108 if ( !matrix.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6111 if ( !matrix.getIdentifier( 1 ).equals( "NEMVE" ) ) {
6114 if ( !matrix.getIdentifier( 2 ).equals( "MONBE" ) ) {
6117 if ( !matrix.getIdentifier( 3 ).equals( "DICDI" ) ) {
6120 if ( !matrix.getIdentifier( 4 ).equals( "ARATH" ) ) {
6123 if ( !matrix.getIdentifier( 5 ).equals( "6" ) ) {
6126 if ( !matrix.getIdentifier( 6 ).equals( "7" ) ) {
6129 if ( !matrix.getIdentifier( 7 ).equals( "8" ) ) {
6132 if ( matrix.getNumberOfCharacters() != ( 66 + 66 + 28 ) ) {
6135 if ( matrix.getState( 0, 4 ) != BinaryStates.ABSENT ) {
6138 if ( matrix.getState( 0, 5 ) != BinaryStates.PRESENT ) {
6141 if ( matrix.getState( 1, 5 ) != BinaryStates.PRESENT ) {
6144 if ( matrix.getState( 7, 154 ) != BinaryStates.ABSENT ) {
6147 if ( matrix.getState( 7, 155 ) != BinaryStates.PRESENT ) {
6150 if ( matrix.getState( 7, 156 ) != BinaryStates.PRESENT ) {
6153 if ( matrix.getState( 7, 157 ) != BinaryStates.ABSENT ) {
6156 if ( matrix.getState( 7, 158 ) != BinaryStates.PRESENT ) {
6159 if ( matrix.getState( 7, 159 ) != BinaryStates.ABSENT ) {
6163 catch ( final Exception e ) {
6164 e.printStackTrace( System.out );
6170 private static boolean testProteinId() {
6172 final ProteinId id1 = new ProteinId( "a" );
6173 final ProteinId id2 = new ProteinId( "a" );
6174 final ProteinId id3 = new ProteinId( "A" );
6175 final ProteinId id4 = new ProteinId( "b" );
6176 if ( !id1.equals( id1 ) ) {
6179 if ( id1.getId().equals( "x" ) ) {
6182 if ( id1.getId().equals( null ) ) {
6185 if ( !id1.equals( id2 ) ) {
6188 if ( id1.equals( id3 ) ) {
6191 if ( id1.hashCode() != id1.hashCode() ) {
6194 if ( id1.hashCode() != id2.hashCode() ) {
6197 if ( id1.hashCode() == id3.hashCode() ) {
6200 if ( id1.compareTo( id1 ) != 0 ) {
6203 if ( id1.compareTo( id2 ) != 0 ) {
6206 if ( id1.compareTo( id3 ) != 0 ) {
6209 if ( id1.compareTo( id4 ) >= 0 ) {
6212 if ( id4.compareTo( id1 ) <= 0 ) {
6215 if ( !id4.getId().equals( "b" ) ) {
6218 final ProteinId id5 = new ProteinId( " C " );
6219 if ( !id5.getId().equals( "C" ) ) {
6222 if ( id5.equals( id1 ) ) {
6226 catch ( final Exception e ) {
6227 e.printStackTrace( System.out );
6233 private static boolean testSpecies() {
6235 final Species s1 = new BasicSpecies( "a" );
6236 final Species s2 = new BasicSpecies( "a" );
6237 final Species s3 = new BasicSpecies( "A" );
6238 final Species s4 = new BasicSpecies( "b" );
6239 if ( !s1.equals( s1 ) ) {
6242 if ( s1.getSpeciesId().equals( "x" ) ) {
6245 if ( s1.getSpeciesId().equals( null ) ) {
6248 if ( !s1.equals( s2 ) ) {
6251 if ( s1.equals( s3 ) ) {
6254 if ( s1.hashCode() != s1.hashCode() ) {
6257 if ( s1.hashCode() != s2.hashCode() ) {
6260 if ( s1.hashCode() == s3.hashCode() ) {
6263 if ( s1.compareTo( s1 ) != 0 ) {
6266 if ( s1.compareTo( s2 ) != 0 ) {
6269 if ( s1.compareTo( s3 ) != 0 ) {
6272 if ( s1.compareTo( s4 ) >= 0 ) {
6275 if ( s4.compareTo( s1 ) <= 0 ) {
6278 if ( !s4.getSpeciesId().equals( "b" ) ) {
6281 final Species s5 = new BasicSpecies( " C " );
6282 if ( !s5.getSpeciesId().equals( "C" ) ) {
6285 if ( s5.equals( s1 ) ) {
6289 catch ( final Exception e ) {
6290 e.printStackTrace( System.out );