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.BasicProtein;
52 import org.forester.protein.BinaryDomainCombination;
53 import org.forester.protein.BinaryDomainCombination.DomainCombinationType;
54 import org.forester.protein.Domain;
55 import org.forester.protein.DomainId;
56 import org.forester.protein.Protein;
57 import org.forester.protein.ProteinId;
58 import org.forester.species.BasicSpecies;
59 import org.forester.species.Species;
60 import org.forester.test.Test;
61 import org.forester.util.ForesterUtil;
63 @SuppressWarnings( "unused")
64 public class TestSurfacing {
66 private final static double ZERO_DIFF = 1.0E-9;
68 public static boolean isEqual( final double a, final double b ) {
69 return ( ( Math.abs( a - b ) ) < TestSurfacing.ZERO_DIFF );
72 private static StringBuffer mapToStringBuffer( final Map<PhylogenyNode, CharacterStateMatrix.BinaryStates> map ) {
73 final StringBuffer sb = new StringBuffer();
74 for( final PhylogenyNode key : map.keySet() ) {
75 if ( !key.isExternal() ) {
76 sb.append( key.getName() );
78 sb.append( map.get( key ).toString() );
79 sb.append( ForesterUtil.getLineSeparator() );
85 public static boolean test( final File test_dir ) {
86 System.out.print( " Domain id: " );
87 if ( !TestSurfacing.testDomainId() ) {
88 System.out.println( "failed." );
91 System.out.println( "OK." );
92 System.out.print( " Protein id: " );
93 if ( !TestSurfacing.testProteinId() ) {
94 System.out.println( "failed." );
97 System.out.println( "OK." );
98 System.out.print( " Species: " );
99 if ( !TestSurfacing.testSpecies() ) {
100 System.out.println( "failed." );
103 System.out.println( "OK." );
104 System.out.print( " Basic domain: " );
105 if ( !TestSurfacing.testBasicDomain() ) {
106 System.out.println( "failed." );
109 System.out.println( "OK." );
110 System.out.print( " Basic protein: " );
111 if ( !TestSurfacing.testBasicProtein() ) {
112 System.out.println( "failed." );
115 System.out.println( "OK." );
116 System.out.print( " Combinable domains: " );
117 if ( !TestSurfacing.testCombinableDomains() ) {
118 System.out.println( "failed." );
121 System.out.println( "OK." );
122 System.out.print( " Directed combinable domains: " );
123 if ( !TestSurfacing.testDirectedCombinableDomains() ) {
124 System.out.println( "failed." );
127 System.out.println( "OK." );
128 System.out.print( " Genome wide specific combinable domains: " );
129 if ( !TestSurfacing.testGenomeWideCombinableDomains() ) {
130 System.out.println( "failed." );
133 System.out.println( "OK." );
134 System.out.print( " Domain architecture based genome similarity calculator: " );
135 if ( !TestSurfacing.testDomainArchitectureBasedGenomeSimilarityCalculator() ) {
136 System.out.println( "failed." );
139 System.out.println( "OK." );
140 System.out.print( " Hmmpfam output parser: " );
141 if ( !TestSurfacing.testHmmPfamOutputParser( test_dir ) ) {
142 System.out.println( "failed." );
145 System.out.println( "OK." );
146 System.out.print( " Hmmpfam output parser with filter: " );
147 if ( !TestSurfacing.testHmmPfamOutputParserWithFilter( test_dir ) ) {
148 System.out.println( "failed." );
151 System.out.println( "OK." );
152 System.out.print( " Combinations based pairwise similarity calculator: " );
153 if ( !TestSurfacing.testCombinationsBasedPairwiseSimilarityCalculator() ) {
154 System.out.println( "failed." );
157 System.out.println( "OK." );
158 System.out.print( " Copy number based pairwise similarity calculator: " );
159 if ( !TestSurfacing.testCopyNumberBasedPairwiseSimilarityCalculator() ) {
162 System.out.println( "OK." );
163 System.out.print( " Domain combination counting: " );
164 if ( !TestSurfacing.testDomainCombinationCounting( test_dir ) ) {
165 System.out.println( "failed." );
168 System.out.println( "OK." );
169 System.out.print( " Basic domain similarity calculator: " );
170 if ( !TestSurfacing.testBasicDomainSimilarityCalculator() ) {
171 System.out.println( "failed." );
174 System.out.println( "OK." );
175 System.out.print( " Basic domain similarity calculator not ignoring species specific domains: " );
176 if ( !TestSurfacing.testBasicDomainSimilarityCalculatorNotIgnoringSpeciesSpeficDomains() ) {
177 System.out.println( "failed." );
180 System.out.println( "OK." );
181 System.out.print( " Basic domain similarity calculator removal of singles: " );
182 if ( !TestSurfacing.testBasicDomainSimilarityCalculatorRemovalOfSingles() ) {
183 System.out.println( "failed." );
186 System.out.println( "OK." );
187 System.out.print( " Domain sorting: " );
188 if ( !TestSurfacing.testDomainSorting() ) {
189 System.out.println( "failed." );
192 System.out.println( "OK." );
193 System.out.print( " Overlap removal: " );
194 if ( !TestSurfacing.testOverlapRemoval() ) {
195 System.out.println( "failed." );
198 System.out.println( "OK." );
199 System.out.print( " Engulfing overlap removal: " );
200 if ( !TestSurfacing.testEngulfingOverlapRemoval() ) {
201 System.out.println( "failed." );
204 System.out.println( "OK." );
205 System.out.print( " Binary domain combination: " );
206 if ( !TestSurfacing.testBinaryDomainCombination() ) {
207 System.out.println( "failed." );
210 System.out.println( "OK." );
211 System.out.print( " Parsimony: " );
212 if ( !TestSurfacing.testParsimony() ) {
213 System.out.println( "failed." );
216 System.out.println( "OK." );
217 System.out.print( " Directedness: " );
218 if ( !TestSurfacing.testDirectedness() ) {
219 System.out.println( "failed." );
222 System.out.println( "OK." );
223 System.out.print( " Directedness and adjacency: " );
224 if ( !TestSurfacing.testDirectednessAndAdjacency() ) {
225 System.out.println( "failed." );
228 System.out.println( "OK." );
229 System.out.print( " Dollo parsimony on secodary features: " );
230 if ( !TestSurfacing.testParsimonyOnSecondaryFeatures() ) {
231 System.out.println( "failed." );
234 System.out.println( "OK." );
235 System.out.print( " Paup log parser: " );
236 if ( !TestSurfacing.testPaupLogParser( test_dir ) ) {
237 System.out.println( "failed." );
240 System.out.println( "OK." );
241 System.out.print( " Binary state matrix to gain loss matrix: " );
242 if ( !TestSurfacing.testBinaryStateMatrixToGainLossMatrix( test_dir ) ) {
243 System.out.println( "failed." );
246 System.out.println( "OK." );
250 private static boolean testBasicDomain() {
252 final Domain pd = new BasicDomain( "id", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
253 if ( !pd.getDomainId().getId().equals( "id" ) ) {
256 if ( pd.getNumber() != 1 ) {
259 if ( pd.getTotalCount() != 4 ) {
262 if ( !pd.equals( new BasicDomain( "id", 22, 111, ( short ) 1, ( short ) 4, 0.2, -12 ) ) ) {
265 final Domain a1 = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
266 final BasicDomain a1_copy = new BasicDomain( "a", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
267 final BasicDomain a1_equal = new BasicDomain( "a", 524, 743994, ( short ) 1, ( short ) 300, 3.0005, 230 );
268 final BasicDomain a2 = new BasicDomain( "a", 1, 10, ( short ) 2, ( short ) 4, 0.1, -12 );
269 final BasicDomain a3 = new BasicDomain( "A", 1, 10, ( short ) 1, ( short ) 4, 0.1, -12 );
270 if ( !a1.equals( a1 ) ) {
273 if ( !a1.equals( a1_copy ) ) {
276 if ( !a1.equals( a1_equal ) ) {
279 if ( !a1.equals( a2 ) ) {
282 if ( a1.equals( a3 ) ) {
285 if ( a1.compareTo( a1 ) != 0 ) {
288 if ( a1.compareTo( a1_copy ) != 0 ) {
291 if ( a1.compareTo( a1_equal ) != 0 ) {
294 if ( a1.compareTo( a2 ) != 0 ) {
297 if ( a1.compareTo( a3 ) != 0 ) {
301 catch ( final Exception e ) {
302 e.printStackTrace( System.out );
308 private static boolean testBasicDomainSimilarityCalculator() {
316 // m 2/(2+3) 0 4/(4+2)
321 // mean = ( 2/5 + 0 + 2/3 + 1/5 + 1/2 + 2/7 ) / 6
341 // m - 2/(2+3) 4/(4+2)
345 // mean = (2/5 + 2/3 + 1/2)/3 =
351 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
352 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
353 final Domain C = new BasicDomain( "C", 1, 2, ( short ) 1, ( short ) 1, 0.3, -12 );
354 final Domain D = new BasicDomain( "D", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
355 final Domain E = new BasicDomain( "E", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
356 final Domain F = new BasicDomain( "F", 1, 2, ( short ) 1, ( short ) 1, 0.01, -12 );
357 final Domain G = new BasicDomain( "G", 1, 2, ( short ) 1, ( short ) 1, 0.001, -12 );
358 final Domain X = new BasicDomain( "X", 1, 2, ( short ) 1, ( short ) 1, 0.0001, -12 );
359 if ( !TestSurfacing.isEqual( X.getPerSequenceScore(), -12 ) ) {
362 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
363 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
364 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
365 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
366 mouse_1.addProteinDomain( A );
367 mouse_1.addProteinDomain( B );
368 mouse_1.addProteinDomain( C );
369 mouse_1.addProteinDomain( D );
370 mouse_1.addProteinDomain( E );
371 rabbit_1.addProteinDomain( A );
372 rabbit_1.addProteinDomain( C );
373 rabbit_1.addProteinDomain( E );
374 rabbit_1.addProteinDomain( F );
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 ciona_1.addProteinDomain( A );
381 ciona_1.addProteinDomain( A );
382 ciona_1.addProteinDomain( A );
383 ciona_1.addProteinDomain( A );
384 ciona_1.addProteinDomain( A );
385 ciona_1.addProteinDomain( F );
386 ciona_1.addProteinDomain( G );
387 ciona_1.addProteinDomain( X );
388 nemve_1.addProteinDomain( A );
389 nemve_1.addProteinDomain( B );
390 nemve_1.addProteinDomain( C );
391 nemve_1.addProteinDomain( D );
392 nemve_1.addProteinDomain( E );
393 nemve_1.addProteinDomain( F );
394 nemve_1.addProteinDomain( G );
395 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
396 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
397 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
398 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
399 protein_list_mouse.add( mouse_1 );
400 protein_list_rabbit.add( rabbit_1 );
401 protein_list_ciona.add( ciona_1 );
402 protein_list_nemve.add( nemve_1 );
403 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
404 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
406 new BasicSpecies( "mouse" ) ) );
407 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
409 new BasicSpecies( "rabbit" ) ) );
410 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
412 new BasicSpecies( "ciona" ) ) );
413 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
415 new BasicSpecies( "nemve" ) ) );
416 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
419 final SortedSet<DomainSimilarity> sims = calc
420 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
424 final Iterator<DomainSimilarity> sims_it = sims.iterator();
425 final DomainSimilarity sa = sims_it.next();
426 if ( !sa.getDomainId().getId().equals( "A" ) ) {
429 if ( sa.getSpeciesData().size() != 4 ) {
432 if ( !sa.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
435 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
438 if ( !sa.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
441 if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
444 if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(),
445 ( 2.0 / 5 + 0 + 2.0 / 3 + 1.0 / 5 + 1.0 / 2 + 2.0 / 7 ) / 6 ) ) {
448 if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), ( 0.23410788192183737 ) ) ) {
451 if ( !TestSurfacing.isEqual( sa.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
454 if ( !TestSurfacing.isEqual( sa.getMinimalSimilarityScore(), ( 0.0 ) ) ) {
457 if ( sa.getN() != 6 ) {
460 if ( sa.getMaximalDifference() != 7 ) {
463 if ( sa.getMaximalDifferenceInCounts() != 3 ) {
466 final DomainSimilarity sb = sims_it.next();
467 if ( !sb.getDomainId().getId().equals( "B" ) ) {
470 if ( sb.getSpeciesData().size() != 2 ) {
473 if ( !sb.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
476 if ( !sb.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
479 if ( !TestSurfacing.isEqual( sb.getMeanSimilarityScore(), 2.0 / 3 ) ) {
482 if ( !TestSurfacing.isEqual( sb.getStandardDeviationOfSimilarityScore(), 0.0 ) ) {
485 if ( !TestSurfacing.isEqual( sb.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
488 if ( !TestSurfacing.isEqual( sb.getMinimalSimilarityScore(), ( 2.0 / 3 ) ) ) {
491 if ( sb.getN() != 1 ) {
494 if ( sb.getMaximalDifference() != 2 ) {
497 if ( sb.getMaximalDifferenceInCounts() != 2 ) {
500 final DomainSimilarity sc = sims_it.next();
501 if ( !sc.getDomainId().getId().equals( "C" ) ) {
504 if ( sc.getSpeciesData().size() != 3 ) {
507 if ( !sc.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
510 if ( !sc.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
513 if ( !sc.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
516 if ( !TestSurfacing.isEqual( sc.getMeanSimilarityScore(), ( 2.0 / 5 + 2.0 / 3 + 1.0 / 2 ) / 3 ) ) {
519 if ( !TestSurfacing.isEqual( sc.getStandardDeviationOfSimilarityScore(), 0.13471506281091264 ) ) {
522 if ( !TestSurfacing.isEqual( sc.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
525 if ( !TestSurfacing.isEqual( sc.getMinimalSimilarityScore(), ( 2.0 / 5 ) ) ) {
528 if ( sc.getN() != 3 ) {
531 if ( sc.getMaximalDifference() != 3 ) {
534 if ( sc.getMaximalDifferenceInCounts() != 3 ) {
537 // mouse : ....ABCDE.....
538 // rabbit: ....A.C.EFFF..
539 // ciona : AAAAA......FGX
540 // nemve : ....ABCDEFG...
544 // m 2/(2+3) 0 4/(4+2)
545 // r - 1/(1+5) 3/(3+3)
549 // mean = ( 2/5 + 0 + 2/3 + 1/6 + 1/2 + 2/8 ) / 6
553 final List<GenomeWideCombinableDomains> cdc_list2 = new ArrayList<GenomeWideCombinableDomains>();
554 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
556 new BasicSpecies( "mouse" ) ) );
557 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
559 new BasicSpecies( "rabbit" ) ) );
560 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
562 new BasicSpecies( "ciona" ) ) );
563 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
565 new BasicSpecies( "nemve" ) ) );
566 final DomainSimilarityCalculator calc2 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
569 final SortedSet<DomainSimilarity> sims2 = calc2
570 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
574 final Iterator<DomainSimilarity> sims_it2 = sims2.iterator();
575 final DomainSimilarity sa2 = sims_it2.next();
576 if ( !sa2.getDomainId().getId().equals( "A" ) ) {
579 if ( sa2.getSpeciesData().size() != 4 ) {
582 if ( !sa2.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
585 if ( !sa2.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
588 if ( !sa2.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
591 if ( !sa2.getSpeciesData().keySet().contains( new BasicSpecies( "rabbit" ) ) ) {
594 if ( !TestSurfacing.isEqual( sa2.getMeanSimilarityScore(),
595 ( 2.0 / 5 + 0 + 2.0 / 3 + 1.0 / 6 + 1.0 / 2 + 2.0 / 8 ) / 6 ) ) {
598 if ( !TestSurfacing.isEqual( sa2.getStandardDeviationOfSimilarityScore(), ( 0.2404663678647683 ) ) ) {
601 if ( !TestSurfacing.isEqual( sa2.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
604 if ( !TestSurfacing.isEqual( sa2.getMinimalSimilarityScore(), ( 0.0 ) ) ) {
607 if ( sa2.getN() != 6 ) {
610 if ( sa2.getMaximalDifference() != 8 ) {
613 if ( sa2.getMaximalDifferenceInCounts() != 3 ) {
616 final Protein ciona_2 = new BasicProtein( "2", "ciona", 0 );
617 ciona_2.addProteinDomain( A );
618 ciona_2.addProteinDomain( A );
619 ciona_2.addProteinDomain( A );
620 ciona_2.addProteinDomain( B );
621 ciona_2.addProteinDomain( B );
622 ciona_2.addProteinDomain( B );
623 ciona_2.addProteinDomain( F );
624 ciona_2.addProteinDomain( F );
625 ciona_2.addProteinDomain( F );
626 ciona_2.addProteinDomain( F );
627 ciona_2.addProteinDomain( G );
628 ciona_2.addProteinDomain( X );
629 final Protein ciona_3 = new BasicProtein( "3", "ciona", 0 );
630 ciona_3.addProteinDomain( A );
631 ciona_3.addProteinDomain( A );
632 ciona_3.addProteinDomain( A );
633 ciona_3.addProteinDomain( A );
634 ciona_3.addProteinDomain( B );
635 ciona_3.addProteinDomain( B );
636 ciona_3.addProteinDomain( X );
637 ciona_3.addProteinDomain( X );
638 protein_list_ciona.add( ciona_2 );
639 protein_list_ciona.add( ciona_3 );
640 final List<GenomeWideCombinableDomains> cdc_list3 = new ArrayList<GenomeWideCombinableDomains>();
641 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
643 new BasicSpecies( "mouse" ) ) );
644 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
646 new BasicSpecies( "rabbit" ) ) );
647 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
649 new BasicSpecies( "ciona" ) ) );
650 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
652 new BasicSpecies( "nemve" ) ) );
653 final DomainSimilarityCalculator calc3 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
656 final SortedSet<DomainSimilarity> sims3 = calc3
657 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
661 final Iterator<DomainSimilarity> sims_it3 = sims3.iterator();
662 final DomainSimilarity sa3 = sims_it3.next();
663 if ( !sa3.getDomainId().getId().equals( "A" ) ) {
666 final SpeciesSpecificDomainSimilariyData ssdsd = sa3.getSpeciesData().get( new BasicSpecies( "ciona" ) );
667 if ( ssdsd.getCombinableDomainIdToCountsMap().size() != 4 ) {
670 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
673 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
676 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
679 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
682 final List<GenomeWideCombinableDomains> cdc_list4 = new ArrayList<GenomeWideCombinableDomains>();
683 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
685 new BasicSpecies( "mouse" ) ) );
686 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
688 new BasicSpecies( "rabbit" ) ) );
689 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
691 new BasicSpecies( "ciona" ) ) );
693 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
695 new BasicSpecies( "nemve" ) ) );
696 final DomainSimilarityCalculator calc4 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
699 final SortedSet<DomainSimilarity> sims4 = calc4
700 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
704 final Iterator<DomainSimilarity> sims_it4 = sims4.iterator();
705 final DomainSimilarity sa4 = sims_it4.next();
706 if ( !sa4.getDomainId().getId().equals( "A" ) ) {
709 final SpeciesSpecificDomainSimilariyData ssdsd4 = sa4.getSpeciesData().get( new BasicSpecies( "ciona" ) );
710 if ( ssdsd4.getCombinableDomainIdToCountsMap().size() != 5 ) {
713 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "A" ) ) != 3 ) {
716 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
719 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
722 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
725 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
728 final SortedSet<DomainSimilarity> sims4_d = calc4
729 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list4, false, true );
730 final Iterator<DomainSimilarity> sims_it4_d = sims4_d.iterator();
731 final DomainSimilarity sa4_d = sims_it4_d.next();
732 if ( !sa4_d.getDomainId().getId().equals( "A" ) ) {
735 if ( sa4_d.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
738 if ( !TestSurfacing.isEqual( sa4_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
739 + 1 - 11.0 / 13 ) / 6.0 ) ) {
742 if ( !TestSurfacing.isEqual( sa4_d.getMaximalSimilarityScore(), 1.0 ) ) {
745 if ( !TestSurfacing.isEqual( sa4_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
748 if ( sa4_d.getN() != 6 ) {
751 final SortedSet<DomainSimilarity> sims4_p = calc4
752 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
756 final Iterator<DomainSimilarity> sims_it4_p = sims4_p.iterator();
757 final DomainSimilarity sa4_p = sims_it4_p.next();
758 if ( !sa4_p.getDomainId().getId().equals( "A" ) ) {
761 if ( sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
764 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "A" ) ) ) {
767 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "B" ) ) ) {
770 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "F" ) ) ) {
773 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "G" ) ) ) {
776 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "X" ) ) ) {
779 if ( !TestSurfacing.isEqual( sa4_p.getMeanSimilarityScore(),
780 ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
783 if ( !TestSurfacing.isEqual( sa4_p.getMaximalSimilarityScore(), 1 ) ) {
786 if ( !TestSurfacing.isEqual( sa4_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
789 if ( sa4_p.getN() != 6 ) {
792 final List<GenomeWideCombinableDomains> cdc_list5 = new ArrayList<GenomeWideCombinableDomains>();
793 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
795 new BasicSpecies( "mouse" ) ) );
796 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
798 new BasicSpecies( "rabbit" ) ) );
799 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
801 new BasicSpecies( "ciona" ) ) );
802 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
804 new BasicSpecies( "nemve" ) ) );
805 final SortedSet<DomainSimilarity> sims5_d = calc4
806 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list5, false, true );
807 final Iterator<DomainSimilarity> sims_it5_d = sims5_d.iterator();
808 final DomainSimilarity sa5_d = sims_it5_d.next();
809 if ( sa5_d.getSpecies().size() != 4 ) {
812 if ( !sa5_d.getSpecies().last().equals( new BasicSpecies( "rabbit" ) ) ) {
815 final SpeciesSpecificDomainSimilariyData ssdsd5 = sa5_d.getSpeciesData().get( new BasicSpecies( "ciona" ) );
816 if ( ssdsd5.getCombinableDomainIdToCountsMap().size() != 4 ) {
819 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
822 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
825 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
828 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
831 if ( !sa5_d.getDomainId().getId().equals( "A" ) ) {
834 final Species ciona = new BasicSpecies( "ciona" );
835 if ( sa5_d.getCombinableDomainIds( ciona ).size() != 4 ) {
838 if ( sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
841 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
844 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
847 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
850 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
853 if ( !TestSurfacing.isEqual( sa5_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
854 + 1 - 11.0 / 13 ) / 6.0 ) ) {
857 if ( !TestSurfacing.isEqual( sa5_d.getMaximalSimilarityScore(), 1.0 ) ) {
860 if ( !TestSurfacing.isEqual( sa5_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
863 if ( sa5_d.getN() != 6 ) {
866 if ( sa5_d.getMaximalDifference() != sa5_d.getMaximalDifferenceInCounts() ) {
869 if ( sa5_d.getMaximalDifference() != 11 ) {
872 if ( sa5_d.getMaximalDifferenceInCounts() != 11 ) {
875 final SortedSet<DomainSimilarity> sims5_p = calc4
876 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
880 final Iterator<DomainSimilarity> sims_it5_p = sims5_p.iterator();
881 final DomainSimilarity sa5_p = sims_it5_p.next();
882 if ( !sa5_p.getDomainId().getId().equals( "A" ) ) {
885 if ( sa5_p.getCombinableDomainIds( ciona ).size() != 4 ) {
888 if ( sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
891 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
894 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
897 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
900 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
903 if ( !TestSurfacing.isEqual( sa5_p.getMeanSimilarityScore(),
904 ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
907 if ( !TestSurfacing.isEqual( sa5_p.getMaximalSimilarityScore(), 1 ) ) {
910 if ( !TestSurfacing.isEqual( sa5_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
913 if ( sa5_p.getN() != 6 ) {
916 if ( sa5_p.getMaximalDifference() != sa5_p.getMaximalDifferenceInCounts() ) {
919 if ( sa5_p.getMaximalDifference() != 2 ) {
922 if ( sa5_p.getMaximalDifferenceInCounts() != 2 ) {
925 final List<GenomeWideCombinableDomains> cdc_list6 = new ArrayList<GenomeWideCombinableDomains>();
926 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
928 new BasicSpecies( "mouse" ) ) );
929 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
931 new BasicSpecies( "rabbit" ) ) );
932 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
934 new BasicSpecies( "ciona" ) ) );
935 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
937 new BasicSpecies( "nemve" ) ) );
938 final SortedSet<DomainSimilarity> sims6_d = calc4
939 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list6, false, true );
940 final Iterator<DomainSimilarity> sims_it6_d = sims6_d.iterator();
941 final DomainSimilarity sa6_d = sims_it6_d.next();
942 if ( sa6_d.getSpecies().size() != 4 ) {
945 if ( !sa6_d.getSpecies().last().equals( new BasicSpecies( "rabbit" ) ) ) {
948 final SpeciesSpecificDomainSimilariyData ssdsd6 = sa6_d.getSpeciesData().get( new BasicSpecies( "ciona" ) );
949 if ( ssdsd6.getCombinableDomainIdToCountsMap().size() != 5 ) {
952 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
955 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
958 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
961 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
964 if ( !sa5_d.getDomainId().getId().equals( "A" ) ) {
967 final Species ciona6 = new BasicSpecies( "ciona" );
968 if ( sa6_d.getCombinableDomainIds( ciona6 ).size() != 5 ) {
971 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "A" ) ) ) {
974 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "B" ) ) ) {
977 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "F" ) ) ) {
980 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "G" ) ) ) {
983 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "X" ) ) ) {
986 if ( !TestSurfacing.isEqual( sa6_d.getMeanSimilarityScore(), ( 1 + 1 - 11.0 / 13 + 1 - 11.0 / 13 + 1 + 1
987 + 1 - 11.0 / 13 ) / 6.0 ) ) {
990 if ( !TestSurfacing.isEqual( sa6_d.getMaximalSimilarityScore(), 1.0 ) ) {
993 if ( !TestSurfacing.isEqual( sa6_d.getMinimalSimilarityScore(), ( 1 - 11.0 / 13 ) ) ) {
996 if ( sa6_d.getN() != 6 ) {
999 if ( sa6_d.getMaximalDifference() != sa6_d.getMaximalDifferenceInCounts() ) {
1002 if ( sa6_d.getMaximalDifference() != 11 ) {
1005 if ( sa6_d.getMaximalDifferenceInCounts() != 11 ) {
1008 final SortedSet<DomainSimilarity> sims6_p = calc4
1009 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
1013 final Iterator<DomainSimilarity> sims_it6_p = sims6_p.iterator();
1014 final DomainSimilarity sa6_p = sims_it6_p.next();
1015 if ( !sa6_p.getDomainId().getId().equals( "A" ) ) {
1018 if ( sa6_p.getCombinableDomainIds( ciona ).size() != 5 ) {
1021 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
1024 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
1027 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
1030 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
1033 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
1036 if ( !TestSurfacing.isEqual( sa6_p.getMeanSimilarityScore(),
1037 ( 1 + 1 - 2.0 / 4 + 1 - 2.0 / 4 + 1 + 1 + 1 - 2.0 / 4 ) / 6.0 ) ) {
1040 if ( !TestSurfacing.isEqual( sa6_p.getMaximalSimilarityScore(), 1 ) ) {
1043 if ( !TestSurfacing.isEqual( sa6_p.getMinimalSimilarityScore(), ( 1 - 2.0 / 4 ) ) ) {
1046 if ( sa6_p.getN() != 6 ) {
1049 if ( sa6_p.getMaximalDifference() != sa6_p.getMaximalDifferenceInCounts() ) {
1052 if ( sa6_p.getMaximalDifference() != 2 ) {
1055 if ( sa6_p.getMaximalDifferenceInCounts() != 2 ) {
1059 catch ( final Exception e ) {
1060 e.printStackTrace( System.out );
1066 private static boolean testBasicDomainSimilarityCalculatorNotIgnoringSpeciesSpeficDomains() {
1068 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
1069 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
1070 final Domain D = new BasicDomain( "D", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
1071 final Domain E = new BasicDomain( "E", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
1072 final Domain F = new BasicDomain( "F", 1, 2, ( short ) 1, ( short ) 1, 0.01, -12 );
1073 final Domain G = new BasicDomain( "G", 1, 2, ( short ) 1, ( short ) 1, 0.001, -12 );
1074 final Domain X = new BasicDomain( "X", 1, 2, ( short ) 1, ( short ) 1, 0.0001, -12 );
1075 if ( !TestSurfacing.isEqual( X.getPerSequenceScore(), -12 ) ) {
1078 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
1079 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
1080 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
1081 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
1082 mouse_1.addProteinDomain( A );
1083 mouse_1.addProteinDomain( D );
1084 mouse_1.addProteinDomain( E );
1085 rabbit_1.addProteinDomain( B );
1086 rabbit_1.addProteinDomain( E );
1087 rabbit_1.addProteinDomain( F );
1088 rabbit_1.addProteinDomain( F );
1089 rabbit_1.addProteinDomain( F );
1090 rabbit_1.addProteinDomain( F );
1091 rabbit_1.addProteinDomain( F );
1092 rabbit_1.addProteinDomain( F );
1093 ciona_1.addProteinDomain( F );
1094 ciona_1.addProteinDomain( G );
1095 ciona_1.addProteinDomain( X );
1096 nemve_1.addProteinDomain( D );
1097 nemve_1.addProteinDomain( E );
1098 nemve_1.addProteinDomain( F );
1099 nemve_1.addProteinDomain( G );
1100 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
1101 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
1102 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
1103 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
1104 protein_list_mouse.add( mouse_1 );
1105 protein_list_rabbit.add( rabbit_1 );
1106 protein_list_ciona.add( ciona_1 );
1107 protein_list_nemve.add( nemve_1 );
1108 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
1109 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
1111 new BasicSpecies( "mouse" ) ) );
1112 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
1114 new BasicSpecies( "rabbit" ) ) );
1115 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
1117 new BasicSpecies( "ciona" ) ) );
1118 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
1120 new BasicSpecies( "nemve" ) ) );
1121 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
1124 final SortedSet<DomainSimilarity> sims = calc
1125 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1129 final Iterator<DomainSimilarity> sims_it = sims.iterator();
1130 final DomainSimilarity sa = sims_it.next();
1131 if ( !sa.getDomainId().getId().equals( "A" ) ) {
1134 if ( sa.getSpeciesData().size() != 1 ) {
1137 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
1140 if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(), 1.0 ) ) {
1143 if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), 0.0 ) ) {
1146 if ( !TestSurfacing.isEqual( sa.getMaximalSimilarityScore(), 1.0 ) ) {
1149 if ( !TestSurfacing.isEqual( sa.getMinimalSimilarityScore(), 1.0 ) ) {
1152 if ( sa.getN() != 0 ) {
1155 if ( sa.getMaximalDifference() != 0 ) {
1158 if ( sa.getMaximalDifferenceInCounts() != 0 ) {
1161 final DomainSimilarity sb = sims_it.next();
1162 if ( !sb.getDomainId().getId().equals( "B" ) ) {
1165 if ( sb.getSpeciesData().size() != 1 ) {
1168 if ( !sb.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
1171 final SortedSet<DomainSimilarity> sims2 = calc
1172 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1176 final Iterator<DomainSimilarity> sims_it2 = sims2.iterator();
1177 final DomainSimilarity sa2 = sims_it2.next();
1178 if ( !sa2.getDomainId().getId().equals( "D" ) ) {
1181 if ( sa2.getSpeciesData().size() != 2 ) {
1185 catch ( final Exception e ) {
1186 e.printStackTrace( System.out );
1192 private static boolean testBasicDomainSimilarityCalculatorRemovalOfSingles() {
1194 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
1195 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
1196 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
1197 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
1198 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
1199 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
1200 mouse_1.addProteinDomain( A );
1201 rabbit_1.addProteinDomain( A );
1202 ciona_1.addProteinDomain( A );
1203 ciona_1.addProteinDomain( A );
1204 ciona_1.addProteinDomain( A );
1205 ciona_1.addProteinDomain( A );
1206 ciona_1.addProteinDomain( A );
1207 nemve_1.addProteinDomain( A );
1208 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
1209 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
1210 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
1211 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
1212 protein_list_mouse.add( mouse_1 );
1213 protein_list_rabbit.add( rabbit_1 );
1214 protein_list_ciona.add( ciona_1 );
1215 protein_list_nemve.add( nemve_1 );
1216 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
1217 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
1219 new BasicSpecies( "mouse" ) ) );
1220 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
1222 new BasicSpecies( "rabbit" ) ) );
1223 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
1225 new BasicSpecies( "ciona" ) ) );
1226 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
1228 new BasicSpecies( "nemve" ) ) );
1229 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
1232 final SortedSet<DomainSimilarity> sims = calc
1233 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1237 if ( sims.size() != 1 ) {
1240 final Iterator<DomainSimilarity> sims_it = sims.iterator();
1241 final DomainSimilarity sa = sims_it.next();
1242 if ( !sa.getDomainId().getId().equals( "A" ) ) {
1245 if ( sa.getSpeciesData().size() != 4 ) {
1248 if ( !sa.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
1251 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
1254 if ( !sa.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
1257 if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
1260 final SortedSet<DomainSimilarity> sims_ns = calc
1261 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1265 if ( sims_ns.size() != 0 ) {
1268 final Protein mouse_2 = new BasicProtein( "1", "mouse", 0 );
1269 final Protein rabbit_2 = new BasicProtein( "1", "rabbit", 0 );
1270 final Protein ciona_2 = new BasicProtein( "1", "ciona", 0 );
1271 final Protein nemve_2 = new BasicProtein( "1", "nemve", 0 );
1272 mouse_2.addProteinDomain( A );
1273 rabbit_2.addProteinDomain( A );
1274 ciona_2.addProteinDomain( A );
1275 ciona_2.addProteinDomain( A );
1276 ciona_2.addProteinDomain( B );
1277 ciona_2.addProteinDomain( A );
1278 ciona_2.addProteinDomain( A );
1279 ciona_2.addProteinDomain( A );
1280 nemve_2.addProteinDomain( A );
1281 final List<Protein> protein_list_mouse2 = new ArrayList<Protein>();
1282 final List<Protein> protein_list_rabbit2 = new ArrayList<Protein>();
1283 final List<Protein> protein_list_ciona2 = new ArrayList<Protein>();
1284 final List<Protein> protein_list_nemve2 = new ArrayList<Protein>();
1285 protein_list_mouse2.add( mouse_2 );
1286 protein_list_rabbit2.add( rabbit_2 );
1287 protein_list_ciona2.add( ciona_2 );
1288 protein_list_nemve2.add( nemve_2 );
1289 final List<GenomeWideCombinableDomains> cdc_list2 = new ArrayList<GenomeWideCombinableDomains>();
1290 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse2,
1292 new BasicSpecies( "mouse" ) ) );
1293 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit2,
1295 new BasicSpecies( "rabbit" ) ) );
1296 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona2,
1298 new BasicSpecies( "ciona" ) ) );
1299 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve2,
1301 new BasicSpecies( "nemve" ) ) );
1302 final SortedSet<DomainSimilarity> sims2 = calc
1303 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1307 if ( sims2.size() != 1 ) {
1311 catch ( final Exception e ) {
1312 e.printStackTrace( System.out );
1318 private static boolean testBasicProtein() {
1320 // A0 A10 B15 A20 B25 A30 B35 B40 C50 A60 C70 D80
1321 final Domain A0 = new BasicDomain( "A", 0, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1322 final Domain A10 = new BasicDomain( "A", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 );
1323 final Domain B15 = new BasicDomain( "B", 11, 16, ( short ) 1, ( short ) 4, 0.1, -12 );
1324 final Domain A20 = new BasicDomain( "A", 20, 100, ( short ) 1, ( short ) 4, 0.1, -12 );
1325 final Domain B25 = new BasicDomain( "B", 25, 26, ( short ) 1, ( short ) 4, 0.1, -12 );
1326 final Domain A30 = new BasicDomain( "A", 30, 31, ( short ) 1, ( short ) 4, 0.1, -12 );
1327 final Domain B35 = new BasicDomain( "B", 31, 40, ( short ) 1, ( short ) 4, 0.1, -12 );
1328 final Domain B40 = new BasicDomain( "B", 40, 600, ( short ) 1, ( short ) 4, 0.1, -12 );
1329 final Domain C50 = new BasicDomain( "C", 50, 59, ( short ) 1, ( short ) 4, 0.1, -12 );
1330 final Domain A60 = new BasicDomain( "A", 60, 395, ( short ) 1, ( short ) 4, 0.1, -12 );
1331 final Domain C70 = new BasicDomain( "C", 70, 71, ( short ) 1, ( short ) 4, 0.1, -12 );
1332 final Domain D80 = new BasicDomain( "D", 80, 81, ( short ) 1, ( short ) 4, 0.1, -12 );
1333 final BasicProtein p = new BasicProtein( "p", "owl", 0 );
1334 p.addProteinDomain( B15 );
1335 p.addProteinDomain( C50 );
1336 p.addProteinDomain( A60 );
1337 p.addProteinDomain( A30 );
1338 p.addProteinDomain( C70 );
1339 p.addProteinDomain( B35 );
1340 p.addProteinDomain( B40 );
1341 p.addProteinDomain( A0 );
1342 p.addProteinDomain( A10 );
1343 p.addProteinDomain( A20 );
1344 p.addProteinDomain( B25 );
1345 p.addProteinDomain( D80 );
1346 List<DomainId> domains_ids = new ArrayList<DomainId>();
1347 domains_ids.add( new DomainId( "A" ) );
1348 domains_ids.add( new DomainId( "B" ) );
1349 domains_ids.add( new DomainId( "C" ) );
1350 if ( !p.contains( domains_ids, false ) ) {
1353 if ( !p.contains( domains_ids, true ) ) {
1356 domains_ids.add( new DomainId( "X" ) );
1357 if ( p.contains( domains_ids, false ) ) {
1360 if ( p.contains( domains_ids, true ) ) {
1363 domains_ids = new ArrayList<DomainId>();
1364 domains_ids.add( new DomainId( "A" ) );
1365 domains_ids.add( new DomainId( "C" ) );
1366 domains_ids.add( new DomainId( "D" ) );
1367 if ( !p.contains( domains_ids, false ) ) {
1370 if ( !p.contains( domains_ids, true ) ) {
1373 domains_ids = new ArrayList<DomainId>();
1374 domains_ids.add( new DomainId( "A" ) );
1375 domains_ids.add( new DomainId( "D" ) );
1376 domains_ids.add( new DomainId( "C" ) );
1377 if ( !p.contains( domains_ids, false ) ) {
1380 if ( p.contains( domains_ids, true ) ) {
1383 domains_ids = new ArrayList<DomainId>();
1384 domains_ids.add( new DomainId( "A" ) );
1385 domains_ids.add( new DomainId( "A" ) );
1386 domains_ids.add( new DomainId( "B" ) );
1387 if ( !p.contains( domains_ids, false ) ) {
1390 if ( !p.contains( domains_ids, true ) ) {
1393 domains_ids = new ArrayList<DomainId>();
1394 domains_ids.add( new DomainId( "A" ) );
1395 domains_ids.add( new DomainId( "A" ) );
1396 domains_ids.add( new DomainId( "A" ) );
1397 domains_ids.add( new DomainId( "B" ) );
1398 domains_ids.add( new DomainId( "B" ) );
1399 if ( !p.contains( domains_ids, false ) ) {
1402 if ( !p.contains( domains_ids, true ) ) {
1405 domains_ids = new ArrayList<DomainId>();
1406 domains_ids.add( new DomainId( "A" ) );
1407 domains_ids.add( new DomainId( "A" ) );
1408 domains_ids.add( new DomainId( "A" ) );
1409 domains_ids.add( new DomainId( "A" ) );
1410 domains_ids.add( new DomainId( "B" ) );
1411 domains_ids.add( new DomainId( "B" ) );
1412 if ( !p.contains( domains_ids, false ) ) {
1415 if ( !p.contains( domains_ids, true ) ) {
1418 domains_ids = new ArrayList<DomainId>();
1419 domains_ids.add( new DomainId( "A" ) );
1420 domains_ids.add( new DomainId( "A" ) );
1421 domains_ids.add( new DomainId( "A" ) );
1422 domains_ids.add( new DomainId( "A" ) );
1423 domains_ids.add( new DomainId( "A" ) );
1424 domains_ids.add( new DomainId( "B" ) );
1425 domains_ids.add( new DomainId( "B" ) );
1426 if ( !p.contains( domains_ids, false ) ) {
1429 if ( p.contains( domains_ids, true ) ) {
1432 domains_ids = new ArrayList<DomainId>();
1433 domains_ids.add( new DomainId( "A" ) );
1434 domains_ids.add( new DomainId( "A" ) );
1435 domains_ids.add( new DomainId( "B" ) );
1436 domains_ids.add( new DomainId( "A" ) );
1437 domains_ids.add( new DomainId( "B" ) );
1438 domains_ids.add( new DomainId( "A" ) );
1439 domains_ids.add( new DomainId( "B" ) );
1440 domains_ids.add( new DomainId( "B" ) );
1441 domains_ids.add( new DomainId( "C" ) );
1442 domains_ids.add( new DomainId( "A" ) );
1443 domains_ids.add( new DomainId( "C" ) );
1444 domains_ids.add( new DomainId( "D" ) );
1445 if ( !p.contains( domains_ids, false ) ) {
1448 if ( !p.contains( domains_ids, true ) ) {
1451 domains_ids = new ArrayList<DomainId>();
1452 domains_ids.add( new DomainId( "A" ) );
1453 domains_ids.add( new DomainId( "B" ) );
1454 domains_ids.add( new DomainId( "A" ) );
1455 domains_ids.add( new DomainId( "B" ) );
1456 domains_ids.add( new DomainId( "A" ) );
1457 domains_ids.add( new DomainId( "B" ) );
1458 domains_ids.add( new DomainId( "B" ) );
1459 domains_ids.add( new DomainId( "A" ) );
1460 domains_ids.add( new DomainId( "C" ) );
1461 domains_ids.add( new DomainId( "D" ) );
1462 if ( !p.contains( domains_ids, false ) ) {
1465 if ( !p.contains( domains_ids, true ) ) {
1468 domains_ids = new ArrayList<DomainId>();
1469 domains_ids.add( new DomainId( "A" ) );
1470 domains_ids.add( new DomainId( "A" ) );
1471 domains_ids.add( new DomainId( "B" ) );
1472 domains_ids.add( new DomainId( "A" ) );
1473 domains_ids.add( new DomainId( "B" ) );
1474 domains_ids.add( new DomainId( "A" ) );
1475 domains_ids.add( new DomainId( "B" ) );
1476 domains_ids.add( new DomainId( "B" ) );
1477 domains_ids.add( new DomainId( "C" ) );
1478 domains_ids.add( new DomainId( "C" ) );
1479 domains_ids.add( new DomainId( "A" ) );
1480 domains_ids.add( new DomainId( "C" ) );
1481 domains_ids.add( new DomainId( "D" ) );
1482 if ( !p.contains( domains_ids, false ) ) {
1485 if ( p.contains( domains_ids, true ) ) {
1488 domains_ids = new ArrayList<DomainId>();
1489 domains_ids.add( new DomainId( "A" ) );
1490 domains_ids.add( new DomainId( "A" ) );
1491 domains_ids.add( new DomainId( "A" ) );
1492 domains_ids.add( new DomainId( "B" ) );
1493 domains_ids.add( new DomainId( "A" ) );
1494 domains_ids.add( new DomainId( "B" ) );
1495 domains_ids.add( new DomainId( "A" ) );
1496 domains_ids.add( new DomainId( "B" ) );
1497 domains_ids.add( new DomainId( "B" ) );
1498 domains_ids.add( new DomainId( "C" ) );
1499 domains_ids.add( new DomainId( "A" ) );
1500 domains_ids.add( new DomainId( "C" ) );
1501 domains_ids.add( new DomainId( "D" ) );
1502 if ( !p.contains( domains_ids, false ) ) {
1505 if ( p.contains( domains_ids, true ) ) {
1508 domains_ids = new ArrayList<DomainId>();
1509 domains_ids.add( new DomainId( "A" ) );
1510 domains_ids.add( new DomainId( "A" ) );
1511 domains_ids.add( new DomainId( "B" ) );
1512 domains_ids.add( new DomainId( "A" ) );
1513 domains_ids.add( new DomainId( "B" ) );
1514 domains_ids.add( new DomainId( "A" ) );
1515 domains_ids.add( new DomainId( "B" ) );
1516 domains_ids.add( new DomainId( "B" ) );
1517 domains_ids.add( new DomainId( "A" ) );
1518 domains_ids.add( new DomainId( "D" ) );
1519 if ( !p.contains( domains_ids, false ) ) {
1522 if ( !p.contains( domains_ids, true ) ) {
1525 domains_ids = new ArrayList<DomainId>();
1526 domains_ids.add( new DomainId( "A" ) );
1527 domains_ids.add( new DomainId( "A" ) );
1528 domains_ids.add( new DomainId( "B" ) );
1529 domains_ids.add( new DomainId( "A" ) );
1530 domains_ids.add( new DomainId( "B" ) );
1531 domains_ids.add( new DomainId( "A" ) );
1532 domains_ids.add( new DomainId( "B" ) );
1533 domains_ids.add( new DomainId( "B" ) );
1534 domains_ids.add( new DomainId( "C" ) );
1535 domains_ids.add( new DomainId( "A" ) );
1536 domains_ids.add( new DomainId( "C" ) );
1537 domains_ids.add( new DomainId( "D" ) );
1538 domains_ids.add( new DomainId( "X" ) );
1539 if ( p.contains( domains_ids, false ) ) {
1542 if ( p.contains( domains_ids, true ) ) {
1545 domains_ids = new ArrayList<DomainId>();
1546 domains_ids.add( new DomainId( "X" ) );
1547 domains_ids.add( new DomainId( "A" ) );
1548 domains_ids.add( new DomainId( "A" ) );
1549 domains_ids.add( new DomainId( "B" ) );
1550 domains_ids.add( new DomainId( "A" ) );
1551 domains_ids.add( new DomainId( "B" ) );
1552 domains_ids.add( new DomainId( "A" ) );
1553 domains_ids.add( new DomainId( "B" ) );
1554 domains_ids.add( new DomainId( "B" ) );
1555 domains_ids.add( new DomainId( "C" ) );
1556 domains_ids.add( new DomainId( "A" ) );
1557 domains_ids.add( new DomainId( "C" ) );
1558 domains_ids.add( new DomainId( "D" ) );
1559 if ( p.contains( domains_ids, false ) ) {
1562 if ( p.contains( domains_ids, true ) ) {
1565 domains_ids = new ArrayList<DomainId>();
1566 domains_ids.add( new DomainId( "A" ) );
1567 domains_ids.add( new DomainId( "A" ) );
1568 domains_ids.add( new DomainId( "B" ) );
1569 domains_ids.add( new DomainId( "A" ) );
1570 domains_ids.add( new DomainId( "B" ) );
1571 domains_ids.add( new DomainId( "B" ) );
1572 domains_ids.add( new DomainId( "A" ) );
1573 domains_ids.add( new DomainId( "B" ) );
1574 domains_ids.add( new DomainId( "C" ) );
1575 domains_ids.add( new DomainId( "A" ) );
1576 domains_ids.add( new DomainId( "C" ) );
1577 domains_ids.add( new DomainId( "D" ) );
1578 if ( !p.contains( domains_ids, false ) ) {
1581 if ( p.contains( domains_ids, true ) ) {
1585 catch ( final Exception e ) {
1586 e.printStackTrace( System.out );
1592 private static boolean testBinaryDomainCombination() {
1594 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "a", "a" );
1595 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "a" );
1596 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "a", "b" );
1597 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "B", "A" );
1598 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "A", "B" );
1599 final BasicBinaryDomainCombination s5 = new BasicBinaryDomainCombination( "c", "a" );
1600 final BasicBinaryDomainCombination s6 = new BasicBinaryDomainCombination( "b", "c" );
1601 final BasicBinaryDomainCombination s7 = new BasicBinaryDomainCombination( "d", "a" );
1602 final BasicBinaryDomainCombination s8 = new BasicBinaryDomainCombination( "b", "d" );
1603 final BinaryDomainCombination s9 = BasicBinaryDomainCombination.createInstance( " z-z=a-aa " );
1604 if ( !s9.toString().equals( "a-aa=z-z" ) ) {
1605 System.out.println( s9.toString() );
1608 if ( !s0.equals( s0 ) ) {
1611 if ( s0.equals( s1 ) ) {
1614 if ( s1.equals( s0 ) ) {
1617 if ( !s1.equals( s2 ) ) {
1620 if ( !s2.equals( s1 ) ) {
1623 if ( s2.equals( s3 ) ) {
1626 if ( s2.equals( s3 ) ) {
1629 if ( s2.equals( s4 ) ) {
1632 final SortedSet<BasicBinaryDomainCombination> sorted = new TreeSet<BasicBinaryDomainCombination>();
1645 if ( sorted.size() != 6 ) {
1648 final DirectedBinaryDomainCombination aa = new DirectedBinaryDomainCombination( "a", "a" );
1649 final DirectedBinaryDomainCombination ba = new DirectedBinaryDomainCombination( "b", "a" );
1650 final DirectedBinaryDomainCombination ab = new DirectedBinaryDomainCombination( "a", "b" );
1651 final DirectedBinaryDomainCombination bb = new DirectedBinaryDomainCombination( "b", "b" );
1652 if ( !aa.equals( aa ) ) {
1655 if ( aa.equals( bb ) ) {
1658 if ( ab.equals( ba ) ) {
1661 if ( ba.equals( ab ) ) {
1664 if ( !ab.equals( ab ) ) {
1667 if ( ab.equals( aa ) ) {
1670 if ( ab.equals( bb ) ) {
1674 catch ( final Exception e ) {
1675 e.printStackTrace( System.out );
1681 private static boolean testBinaryStateMatrixToGainLossMatrix( final File test_dir ) {
1682 final BinaryStates I = BinaryStates.PRESENT;
1683 final BinaryStates O = BinaryStates.ABSENT;
1685 final CharacterStateMatrix<BinaryStates> binary_states_matrix_0 = new BasicCharacterStateMatrix<BinaryStates>( 7,
1687 binary_states_matrix_0.setIdentifier( 0, "A" );
1688 binary_states_matrix_0.setIdentifier( 1, "B" );
1689 binary_states_matrix_0.setIdentifier( 2, "C" );
1690 binary_states_matrix_0.setIdentifier( 3, "D" );
1691 binary_states_matrix_0.setIdentifier( 4, "1" );
1692 binary_states_matrix_0.setIdentifier( 5, "2" );
1693 binary_states_matrix_0.setIdentifier( 6, "3" );
1694 binary_states_matrix_0.setState( 0, 0, O );
1695 binary_states_matrix_0.setState( 1, 0, O );
1696 binary_states_matrix_0.setState( 2, 0, O );
1697 binary_states_matrix_0.setState( 3, 0, O );
1698 binary_states_matrix_0.setState( 4, 0, O );
1699 binary_states_matrix_0.setState( 5, 0, O );
1700 binary_states_matrix_0.setState( 6, 0, O );
1701 binary_states_matrix_0.setState( 0, 1, I );
1702 binary_states_matrix_0.setState( 1, 1, O );
1703 binary_states_matrix_0.setState( 2, 1, O );
1704 binary_states_matrix_0.setState( 3, 1, O );
1705 binary_states_matrix_0.setState( 4, 1, O );
1706 binary_states_matrix_0.setState( 5, 1, O );
1707 binary_states_matrix_0.setState( 6, 1, O );
1708 binary_states_matrix_0.setState( 0, 2, O );
1709 binary_states_matrix_0.setState( 1, 2, O );
1710 binary_states_matrix_0.setState( 2, 2, O );
1711 binary_states_matrix_0.setState( 3, 2, O );
1712 binary_states_matrix_0.setState( 4, 2, I );
1713 binary_states_matrix_0.setState( 5, 2, O );
1714 binary_states_matrix_0.setState( 6, 2, O );
1715 binary_states_matrix_0.setState( 0, 3, I );
1716 binary_states_matrix_0.setState( 1, 3, O );
1717 binary_states_matrix_0.setState( 2, 3, O );
1718 binary_states_matrix_0.setState( 3, 3, O );
1719 binary_states_matrix_0.setState( 4, 3, I );
1720 binary_states_matrix_0.setState( 5, 3, O );
1721 binary_states_matrix_0.setState( 6, 3, I );
1722 binary_states_matrix_0.setState( 0, 4, I );
1723 binary_states_matrix_0.setState( 1, 4, O );
1724 binary_states_matrix_0.setState( 2, 4, I );
1725 binary_states_matrix_0.setState( 3, 4, O );
1726 binary_states_matrix_0.setState( 4, 4, I );
1727 binary_states_matrix_0.setState( 5, 4, O );
1728 binary_states_matrix_0.setState( 6, 4, I );
1729 binary_states_matrix_0.setState( 0, 5, I );
1730 binary_states_matrix_0.setState( 1, 5, I );
1731 binary_states_matrix_0.setState( 2, 5, I );
1732 binary_states_matrix_0.setState( 3, 5, I );
1733 binary_states_matrix_0.setState( 4, 5, I );
1734 binary_states_matrix_0.setState( 5, 5, I );
1735 binary_states_matrix_0.setState( 6, 5, I );
1736 final String[] character_labels_0 = new String[ 6 ];
1737 character_labels_0[ 0 ] = "first";
1738 character_labels_0[ 1 ] = "second";
1739 character_labels_0[ 2 ] = "third";
1740 character_labels_0[ 3 ] = "forth";
1741 character_labels_0[ 4 ] = "fifth";
1742 character_labels_0[ 5 ] = "sixth";
1743 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1744 final Phylogeny phylogeny_0 = factory.create( "(((A,B)1,C)2,D)3", new NHXParser() )[ 0 ];
1745 final DomainParsimonyCalculator dom_pars = DomainParsimonyCalculator.createInstance( phylogeny_0 );
1746 dom_pars.executeOnGivenBinaryStatesMatrix( binary_states_matrix_0, character_labels_0 );
1747 final CharacterStateMatrix<GainLossStates> gl_matrix_0 = dom_pars.getGainLossMatrix();
1748 // final StringWriter sw = new StringWriter();
1749 // gl_matrix_0.toWriter( sw );
1750 // System.out.println( sw.toString() );
1751 if ( dom_pars.getCost() != 13 ) {
1754 if ( dom_pars.getTotalGains() != 5 ) {
1757 if ( dom_pars.getTotalLosses() != 8 ) {
1760 if ( dom_pars.getTotalUnchanged() != 29 ) {
1763 if ( gl_matrix_0.getState( "A", 1 ) != GainLossStates.GAIN ) {
1766 if ( gl_matrix_0.getState( "A", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1769 if ( gl_matrix_0.getState( "B", 4 ) != GainLossStates.LOSS ) {
1772 if ( gl_matrix_0.getState( "C", 4 ) != GainLossStates.GAIN ) {
1775 if ( gl_matrix_0.getState( "D", 4 ) != GainLossStates.LOSS ) {
1778 if ( gl_matrix_0.getState( "1", 4 ) != GainLossStates.GAIN ) {
1781 if ( gl_matrix_0.getState( "2", 4 ) != GainLossStates.LOSS ) {
1784 if ( gl_matrix_0.getState( "3", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1788 catch ( final Exception e ) {
1789 e.printStackTrace( System.out );
1795 private static boolean testCombinableDomains() {
1797 final Domain key0 = new BasicDomain( "key0", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1798 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1799 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1800 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1801 final CombinableDomains cd0 = new BasicCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
1802 cd0.addCombinableDomain( a.getDomainId() );
1803 cd0.addCombinableDomain( b.getDomainId() );
1804 cd0.addCombinableDomain( b.getDomainId() );
1805 cd0.addCombinableDomain( c.getDomainId() );
1806 cd0.addCombinableDomain( c.getDomainId() );
1807 cd0.addCombinableDomain( c.getDomainId() );
1808 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
1811 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
1814 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
1817 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
1820 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
1823 if ( cd0.getAllDomains().size() != 4 ) {
1826 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
1829 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
1832 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
1835 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
1838 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
1841 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "key0", "a" );
1842 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "key0" );
1843 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "key0", "c" );
1844 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "key0", "cc" );
1845 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "c", "key0" );
1846 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
1849 if ( !cd0.toBinaryDomainCombinations().contains( s1 ) ) {
1852 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
1855 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
1858 if ( !cd0.toBinaryDomainCombinations().contains( s4 ) ) {
1861 final Domain key1 = new BasicDomain( "key1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1862 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1863 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1864 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1865 final CombinableDomains cd1 = new BasicCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
1866 cd1.addCombinableDomain( a1.getDomainId() );
1867 cd1.addCombinableDomain( b1.getDomainId() );
1868 cd1.addCombinableDomain( c1.getDomainId() );
1869 cd1.addCombinableDomain( key1.getDomainId() );
1870 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
1873 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
1876 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
1879 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
1882 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
1885 if ( cd1.getAllDomains().size() != 4 ) {
1888 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
1891 final BasicBinaryDomainCombination kk = new BasicBinaryDomainCombination( "key1", "key1" );
1892 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
1896 catch ( final Exception e ) {
1897 e.printStackTrace( System.out );
1903 private static boolean testCombinationsBasedPairwiseSimilarityCalculator() {
1905 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1906 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1907 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1908 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1909 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1910 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1911 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1912 new BasicSpecies( "rabbit" ) );
1913 one.addCombinableDomain( a.getDomainId() );
1914 one.addCombinableDomain( a.getDomainId() );
1915 two.addCombinableDomain( new BasicDomain( "A", 1, 5, ( short ) 1, ( short ) 4, 0.1, -12 ).getDomainId() );
1916 two.addCombinableDomain( b.getDomainId() );
1917 two.addCombinableDomain( c.getDomainId() );
1918 final PairwiseDomainSimilarityCalculator calc = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1919 final PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1920 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 / ( 1 + 2 ) ) ) {
1923 if ( s1.getDifferenceInCounts() != ( 1 - 3 ) ) {
1926 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s1 ).getNumberOfDifferentDomains() != 2 ) {
1929 one.addCombinableDomain( b.getDomainId() );
1930 one.addCombinableDomain( c.getDomainId() );
1931 final PairwiseDomainSimilarity s2 = calc.calculateSimilarity( one, two );
1932 if ( !TestSurfacing.isEqual( s2.getSimilarityScore(), 3.0 / ( 0 + 3 ) ) ) {
1935 if ( s2.getDifferenceInCounts() != 0 ) {
1938 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s2 ).getNumberOfDifferentDomains() != 0 ) {
1941 final Domain d = new BasicDomain( "D", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1942 final Domain e = new BasicDomain( "E", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1943 final Domain f = new BasicDomain( "F", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1944 one.addCombinableDomain( d.getDomainId() );
1945 one.addCombinableDomain( d.getDomainId() );
1946 one.addCombinableDomain( e.getDomainId() );
1947 one.addCombinableDomain( f.getDomainId() );
1948 final PairwiseDomainSimilarity s3 = calc.calculateSimilarity( one, two );
1949 if ( !TestSurfacing.isEqual( s3.getSimilarityScore(), 3.0 / ( 3 + 3 ) ) ) {
1952 if ( s3.getDifferenceInCounts() != ( 6 - 3 ) ) {
1955 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s3 ).getNumberOfDifferentDomains() != 3 ) {
1958 final Domain aaa = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1959 final Domain bbb = new BasicDomain( "bbb", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1960 final Domain three_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1961 final Domain four_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1962 final CombinableDomains three = new BasicCombinableDomains( three_key.getDomainId(),
1963 new BasicSpecies( "mouse" ) );
1964 final CombinableDomains four = new BasicCombinableDomains( four_key.getDomainId(),
1965 new BasicSpecies( "rabbit" ) );
1966 three.addCombinableDomain( aaa.getDomainId() );
1967 four.addCombinableDomain( bbb.getDomainId() );
1968 final PairwiseDomainSimilarityCalculator calc2 = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1969 final PairwiseDomainSimilarity s4 = calc2.calculateSimilarity( three, four );
1970 if ( !TestSurfacing.isEqual( s4.getSimilarityScore(), 0.0 / ( 0 + 2 ) ) ) {
1973 final Domain aaa2 = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1974 four.addCombinableDomain( aaa2.getDomainId() );
1975 final PairwiseDomainSimilarity s5 = calc.calculateSimilarity( three, four );
1976 if ( !TestSurfacing.isEqual( s5.getSimilarityScore(), 1.0 / ( 1 + 1 ) ) ) {
1980 catch ( final Exception e ) {
1981 e.printStackTrace( System.out );
1987 private static boolean testCopyNumberBasedPairwiseSimilarityCalculator() {
1989 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1990 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1991 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1992 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1993 new BasicSpecies( "rabbit" ) );
1994 one.setKeyDomainCount( 2 );
1995 two.setKeyDomainCount( 3 );
1996 final PairwiseDomainSimilarityCalculator calc = new DomainCountsBasedPairwiseSimilarityCalculator();
1997 PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1998 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 3 - 2.0 ) / ( 2 + 3 ) ) ) {
2001 if ( s1.getDifferenceInCounts() != ( 2 - 3 ) ) {
2004 one.setKeyDomainCount( 1 );
2005 two.setKeyDomainCount( 1 );
2006 s1 = calc.calculateSimilarity( one, two );
2007 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 ) ) {
2010 if ( s1.getDifferenceInCounts() != ( 1 - 1 ) ) {
2013 one.setKeyDomainCount( 1 );
2014 two.setKeyDomainCount( 1000 );
2015 s1 = calc.calculateSimilarity( one, two );
2016 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - 999.0 / 1001 ) ) {
2019 if ( s1.getDifferenceInCounts() != ( 1 - 1000 ) ) {
2023 catch ( final Exception e ) {
2024 e.printStackTrace( System.out );
2030 private static boolean testDirectedCombinableDomains() {
2032 final Domain key0 = new BasicDomain( "key0", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 );
2033 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2034 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2035 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2036 final CombinableDomains cd0 = new DirectedCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
2037 cd0.addCombinableDomain( a.getDomainId() );
2038 cd0.addCombinableDomain( b.getDomainId() );
2039 cd0.addCombinableDomain( b.getDomainId() );
2040 cd0.addCombinableDomain( c.getDomainId() );
2041 cd0.addCombinableDomain( c.getDomainId() );
2042 cd0.addCombinableDomain( c.getDomainId() );
2043 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
2046 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
2049 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
2052 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
2055 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
2058 if ( cd0.getAllDomains().size() != 4 ) {
2061 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
2064 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
2067 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
2070 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
2073 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
2076 final BinaryDomainCombination s0 = new DirectedBinaryDomainCombination( "key0", "a" );
2077 final BinaryDomainCombination s1 = new DirectedBinaryDomainCombination( "b", "key0" );
2078 final BinaryDomainCombination s2 = new DirectedBinaryDomainCombination( "key0", "c" );
2079 final BinaryDomainCombination s3 = new DirectedBinaryDomainCombination( "key0", "cc" );
2080 final BinaryDomainCombination s4 = new DirectedBinaryDomainCombination( "a", "b" );
2081 final BinaryDomainCombination s5 = new DirectedBinaryDomainCombination( "b", "a" );
2082 final BinaryDomainCombination s6 = new DirectedBinaryDomainCombination( "key0", "b" );
2083 final BinaryDomainCombination s7 = new DirectedBinaryDomainCombination( "a", "key0" );
2084 final BinaryDomainCombination s8 = new DirectedBinaryDomainCombination( "c", "key0" );
2085 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
2088 if ( cd0.toBinaryDomainCombinations().contains( s1 ) ) {
2091 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
2094 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
2097 if ( cd0.toBinaryDomainCombinations().contains( s4 ) ) {
2100 if ( cd0.toBinaryDomainCombinations().contains( s5 ) ) {
2103 if ( !cd0.toBinaryDomainCombinations().contains( s6 ) ) {
2106 if ( cd0.toBinaryDomainCombinations().contains( s7 ) ) {
2109 if ( cd0.toBinaryDomainCombinations().contains( s8 ) ) {
2112 final Domain key1 = new BasicDomain( "key1", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 );
2113 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2114 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2115 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2116 final CombinableDomains cd1 = new DirectedCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
2117 cd1.addCombinableDomain( a1.getDomainId() );
2118 cd1.addCombinableDomain( b1.getDomainId() );
2119 cd1.addCombinableDomain( c1.getDomainId() );
2120 cd1.addCombinableDomain( key1.getDomainId() );
2121 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
2124 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
2127 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
2130 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
2133 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
2136 if ( cd1.getAllDomains().size() != 4 ) {
2139 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
2142 final BinaryDomainCombination kk = new DirectedBinaryDomainCombination( "key1", "key1" );
2143 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
2147 catch ( final Exception e ) {
2148 e.printStackTrace( System.out );
2154 private static boolean testDirectedness() {
2156 final BinaryStates X = BinaryStates.PRESENT;
2157 final BinaryStates O = BinaryStates.ABSENT;
2158 final GainLossStates G = GainLossStates.GAIN;
2159 final GainLossStates L = GainLossStates.LOSS;
2160 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
2161 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
2162 final Protein one_1 = new BasicProtein( "one", "1", 0 );
2163 final Protein two_1 = new BasicProtein( "two", "1", 0 );
2164 final Protein three_1 = new BasicProtein( "three", "1", 0 );
2165 final Protein four_1 = new BasicProtein( "four", "1", 0 );
2166 final Protein five_1 = new BasicProtein( "five", "1", 0 );
2167 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2168 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2169 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2170 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2171 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2172 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2173 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2174 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2175 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2176 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2177 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2178 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2179 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2180 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2181 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2182 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2183 final List<Protein> list_1 = new ArrayList<Protein>();
2184 list_1.add( one_1 );
2185 list_1.add( two_1 );
2186 list_1.add( three_1 );
2187 list_1.add( four_1 );
2188 list_1.add( five_1 );
2189 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2190 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED );
2191 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "B" ) ) ) {
2194 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "A" ) ) ) {
2197 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "A" ) ) ) {
2200 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "C" ) ) ) {
2203 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "A" ) ) ) {
2206 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "C" ) ) ) {
2209 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "X" ) ) ) {
2212 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2215 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
2218 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2221 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2224 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "A" ) ) ) {
2227 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "B" ) ) ) {
2230 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2233 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2236 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2239 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
2242 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2245 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "N" ) ) ) {
2248 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "M" ) ) ) {
2251 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "P" ) ) ) {
2254 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "P" ) ) ) {
2257 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "N" ) ) ) {
2260 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "M" ) ) ) {
2263 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2266 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2269 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "B" ) ) ) {
2272 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
2273 // gwcd_list.add( gwcd_1 );
2274 // gwcd_list.add( gwcd_2 );
2275 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
2276 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
2277 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
2278 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
2279 // if ( matrix_d.getState( 0, 0 ) != X ) {
2282 // if ( matrix_bc.getState( 0, 0 ) != X ) {
2287 // final BasicCharacterStateMatrix<BinaryStates> dm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
2288 // { X, X, X, X, X, X }, { X, X, X, X, X, X } } );
2289 // if ( !matrix_d.equals( dm ) ) {
2292 // final BasicCharacterStateMatrix<BinaryStates> bcm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
2293 // { X, O, X, X, X, X, O, X, X, O, X, X }, { X, X, X, O, O, O, O, X, O, O, X, X } } );
2294 // if ( !matrix_d.equals( dm ) ) {
2297 //``````````````````````````
2298 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
2299 // gwcd_list.add( one );
2300 // gwcd_list.add( two );
2301 // gwcd_list.add( three );
2302 // gwcd_list.add( four );
2303 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimony
2304 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
2305 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimony
2306 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
2307 // // System.out.println( "d:" );
2308 // // System.out.println(matrix_d.toStringBuffer().toString() );
2309 // // System.out.println( "bc:" );
2310 // // System.out.println(matrix_bc.toStringBuffer().toString() );
2311 // // 1 a b c e f g h l m
2312 // // 2 a b c e f g i n o
2313 // // 3 a b d e f g j p q
2315 // if ( matrix_d.getState( 0, 0 ) != X ) {
2318 // if ( matrix_d.getState( 0, 1 ) != X ) {
2321 // if ( matrix_d.getState( 0, 2 ) != X ) {
2324 // if ( matrix_d.getState( 0, 3 ) != O ) {
2327 // if ( matrix_d.getState( 0, 4 ) != X ) {
2330 // if ( matrix_d.getState( 0, 5 ) != X ) {
2333 // if ( matrix_d.getState( 0, 6 ) != X ) {
2336 // if ( matrix_d.getState( 0, 7 ) != X ) {
2339 // if ( matrix_d.getState( 0, 8 ) != O ) {
2342 // // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
2343 // // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
2344 // // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
2346 // if ( matrix_bc.getState( 0, 0 ) != X ) {
2349 // if ( matrix_bc.getState( 0, 1 ) != X ) {
2352 // if ( matrix_bc.getState( 0, 2 ) != X ) {
2355 // if ( matrix_bc.getState( 0, 3 ) != O ) {
2358 // if ( matrix_bc.getState( 0, 4 ) != X ) {
2361 // if ( matrix_bc.getState( 1, 0 ) != O ) {
2364 // if ( matrix_bc.getState( 1, 1 ) != X ) {
2367 // if ( matrix_bc.getState( 1, 2 ) != X ) {
2370 // if ( matrix_bc.getState( 1, 3 ) != O ) {
2373 // if ( matrix_bc.getState( 1, 4 ) != X ) {
2376 // if ( matrix_bc.getState( 2, 0 ) != O ) {
2379 // if ( matrix_bc.getState( 2, 1 ) != X ) {
2382 // if ( matrix_bc.getState( 2, 2 ) != O ) {
2385 // if ( matrix_bc.getState( 2, 3 ) != X ) {
2388 // if ( matrix_bc.getState( 2, 4 ) != X ) {
2391 // final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
2392 // final String p0_str = "((one,two)1-2,(three,four)3-4)root";
2393 // final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
2394 // final DomainParsimony dp0 = DomainParsimony.createInstance( p0, gwcd_list );
2395 // dp0.executeDolloParsimonyOnDomainPresence();
2396 // final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
2397 // final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
2398 // dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2399 // final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
2400 // final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
2401 // if ( is_matrix_d.getState( "root", "A" ) != X ) {
2404 // if ( is_matrix_d.getState( "root", "B" ) != X ) {
2407 // if ( is_matrix_d.getState( "root", "C" ) != O ) {
2410 // if ( is_matrix_d.getState( "root", "D" ) != O ) {
2413 // if ( is_matrix_d.getState( "root", "E" ) != X ) {
2416 // if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
2419 // if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
2422 // if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
2425 // if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
2428 // if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
2431 // if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
2434 // if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
2437 // if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
2440 // if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
2443 // if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
2446 // if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
2449 // if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
2452 // if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
2455 // if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
2458 // final Protein ab_1 = new BasicProtein( "ab", "one" );
2459 // ab_1.addProteinDomain( a );
2460 // ab_1.addProteinDomain( b );
2461 // final Protein ac_1 = new BasicProtein( "ac", "one" );
2462 // ac_1.addProteinDomain( a );
2463 // ac_1.addProteinDomain( c );
2464 // final Protein de_1 = new BasicProtein( "de", "one" );
2465 // de_1.addProteinDomain( d );
2466 // de_1.addProteinDomain( e );
2467 // final Protein ac_2 = new BasicProtein( "ac", "two" );
2468 // ac_2.addProteinDomain( a );
2469 // ac_2.addProteinDomain( c );
2470 // final Protein ab_3 = new BasicProtein( "ab", "three" );
2471 // ab_3.addProteinDomain( a );
2472 // ab_3.addProteinDomain( b );
2473 // final Protein de_4 = new BasicProtein( "de", "four" );
2474 // de_4.addProteinDomain( d );
2475 // de_4.addProteinDomain( e );
2476 // final Protein ab_6 = new BasicProtein( "ab", "six" );
2477 // ab_6.addProteinDomain( a );
2478 // ab_6.addProteinDomain( b );
2479 // final List<Protein> spec_one = new ArrayList<Protein>();
2480 // final List<Protein> spec_two = new ArrayList<Protein>();
2481 // final List<Protein> spec_three = new ArrayList<Protein>();
2482 // final List<Protein> spec_four = new ArrayList<Protein>();
2483 // final List<Protein> spec_five = new ArrayList<Protein>();
2484 // final List<Protein> spec_six = new ArrayList<Protein>();
2485 // final List<Protein> spec_seven = new ArrayList<Protein>();
2486 // spec_one.add( ab_1 );
2487 // spec_one.add( ac_1 );
2488 // spec_one.add( de_1 );
2489 // spec_two.add( ac_2 );
2490 // spec_three.add( ab_3 );
2491 // spec_four.add( de_4 );
2492 // spec_six.add( ab_6 );
2493 // final GenomeWideCombinableDomains one_gwcd = BasicGenomeWideCombinableDomains
2494 // .createInstance( spec_one, false, new BasicSpecies( "one" ), false );
2495 // final GenomeWideCombinableDomains two_gwcd = BasicGenomeWideCombinableDomains
2496 // .createInstance( spec_two, false, new BasicSpecies( "two" ), false );
2497 // final GenomeWideCombinableDomains three_gwcd = BasicGenomeWideCombinableDomains
2498 // .createInstance( spec_three, false, new BasicSpecies( "three" ), false );
2499 // final GenomeWideCombinableDomains four_gwcd = BasicGenomeWideCombinableDomains
2500 // .createInstance( spec_four, false, new BasicSpecies( "four" ), false );
2501 // final GenomeWideCombinableDomains five_gwcd = BasicGenomeWideCombinableDomains
2502 // .createInstance( spec_five, false, new BasicSpecies( "five" ), false );
2503 // final GenomeWideCombinableDomains six_gwcd = BasicGenomeWideCombinableDomains
2504 // .createInstance( spec_six, false, new BasicSpecies( "six" ), false );
2505 // final GenomeWideCombinableDomains seven_gwcd = BasicGenomeWideCombinableDomains
2506 // .createInstance( spec_seven, false, new BasicSpecies( "seven" ), false
2508 // final List<GenomeWideCombinableDomains> gwcd_list1 = new ArrayList<GenomeWideCombinableDomains>();
2509 // gwcd_list1.add( one_gwcd );
2510 // gwcd_list1.add( two_gwcd );
2511 // gwcd_list1.add( three_gwcd );
2512 // gwcd_list1.add( four_gwcd );
2513 // gwcd_list1.add( five_gwcd );
2514 // gwcd_list1.add( six_gwcd );
2515 // gwcd_list1.add( seven_gwcd );
2516 // final PhylogenyFactory factory1 = ParserBasedPhylogenyFactory.getInstance();
2517 // final String p1_str = "(((((one,two)12,three)123,(four,five)45)12345,six)123456,seven)root";
2518 // final Phylogeny p1 = factory1.create( p1_str, new NHXParser() )[ 0 ];
2519 // final DomainParsimony dp1 = DomainParsimony.createInstance( p1, gwcd_list1 );
2520 // dp1.executeDolloParsimonyOnDomainPresence();
2521 // final CharacterStateMatrix<GainLossStates> gl_dollo_d = dp1.getGainLossMatrix();
2522 // final CharacterStateMatrix<BinaryStates> i_dollo_d = dp1.getInternalStatesMatrix();
2523 // if ( dp1.getCost() != 14 ) {
2526 // if ( dp1.getTotalGains() != 5 ) {
2529 // if ( dp1.getTotalLosses() != 9 ) {
2532 // if ( dp1.getTotalUnchanged() != 51 ) {
2535 // if ( dp1.getNetGainsOnNode( "45" ) != -2 ) {
2538 // if ( dp1.getSumOfGainsOnNode( "45" ) != 0 ) {
2541 // if ( dp1.getSumOfLossesOnNode( "45" ) != 2 ) {
2544 // if ( dp1.getSumOfUnchangedOnNode( "45" ) != 3 ) {
2547 // if ( dp1.getSumOfUnchangedPresentOnNode( "45" ) != 2 ) {
2550 // if ( dp1.getSumOfUnchangedAbsentOnNode( "45" ) != 1 ) {
2553 // if ( dp1.getUnitsGainedOnNode( "45" ).contains( "A" ) ) {
2556 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A" ) ) {
2559 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "B" ) ) {
2562 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D" ) ) {
2565 // if ( !dp1.getUnitsOnNode( "12" ).contains( "A" ) ) {
2568 // if ( !dp1.getUnitsOnNode( "12" ).contains( "B" ) ) {
2571 // if ( !dp1.getUnitsOnNode( "12" ).contains( "C" ) ) {
2574 // if ( !dp1.getUnitsOnNode( "12" ).contains( "D" ) ) {
2577 // if ( !dp1.getUnitsOnNode( "12" ).contains( "E" ) ) {
2580 // if ( dp1.getNetGainsOnNode( "123456" ) != 2 ) {
2583 // if ( dp1.getSumOfGainsOnNode( "123456" ) != 2 ) {
2586 // dp1.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2587 // final CharacterStateMatrix<GainLossStates> gl_dollo_bc = dp1.getGainLossMatrix();
2588 // final CharacterStateMatrix<BinaryStates> i_dollo_bc = dp1.getInternalStatesMatrix();
2589 // if ( dp1.getCost() != 8 ) {
2592 // if ( dp1.getTotalGains() != 3 ) {
2595 // if ( dp1.getTotalLosses() != 5 ) {
2598 // if ( dp1.getTotalUnchanged() != 31 ) {
2601 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2604 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D=E" ) ) {
2607 // dp1.executeFitchParsimonyOnDomainPresence();
2608 // final CharacterStateMatrix<GainLossStates> gl_fitch_d = dp1.getGainLossMatrix();
2609 // final CharacterStateMatrix<BinaryStates> i_fitch_d = dp1.getInternalStatesMatrix();
2610 // if ( dp1.getCost() != 10 ) {
2613 // if ( dp1.getTotalGains() != 7 ) {
2616 // if ( dp1.getTotalLosses() != 3 ) {
2619 // if ( dp1.getTotalUnchanged() != 55 ) {
2622 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "E" ) ) {
2625 // dp1.executeFitchParsimonyOnBinaryDomainCombintion();
2626 // final CharacterStateMatrix<GainLossStates> gl_fitch_bc = dp1.getGainLossMatrix();
2627 // final CharacterStateMatrix<BinaryStates> i_fitch_bc = dp1.getInternalStatesMatrix();
2628 // if ( dp1.getCost() != 6 ) {
2631 // if ( dp1.getTotalGains() != 4 ) {
2634 // if ( dp1.getTotalLosses() != 2 ) {
2637 // if ( dp1.getTotalUnchanged() != 33 ) {
2640 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2643 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "D=E" ) ) {
2646 // if ( dp1.getNetGainsOnNode( "two" ) != -1 ) {
2649 // if ( dp1.getNetGainsOnNode( "123" ) != 0 ) {
2652 // if ( dp1.getSumOfUnchangedPresentOnNode( "123" ) != 1 ) {
2655 // if ( dp1.getSumOfUnchangedAbsentOnNode( "123" ) != 2 ) {
2658 // if ( dp1.getSumOfUnchangedOnNode( "123" ) != 3 ) {
2661 // if ( dp1.getSumOfUnchangedOnNode( "two" ) != 2 ) {
2664 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "two" ).contains( "D=E" ) ) {
2667 // if ( !dp1.getUnitsUnchangedPresentOnNode( "two" ).contains( "A=C" ) ) {
2670 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "A=C" ) ) {
2673 // if ( !dp1.getUnitsUnchangedPresentOnNode( "123" ).contains( "A=B" ) ) {
2676 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "D=E" ) ) {
2679 // CharacterStateMatrix<BinaryStates> bsm = null;
2680 // CharacterStateMatrix<GainLossStates> glm = null;
2681 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, X, X },
2682 // { 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 } } );
2683 // if ( !bsm.equals( i_dollo_d ) ) {
2686 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, O, O },
2687 // { 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 } } );
2688 // if ( !bsm.equals( i_fitch_d ) ) {
2691 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, P, P },
2692 // { 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 },
2693 // { 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 },
2694 // { A, A, A, A, A }, { A, A, A, A, A } } );
2695 // if ( !glm.equals( gl_dollo_d ) ) {
2698 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, G, G },
2699 // { 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 },
2700 // { 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 },
2701 // { A, A, A, A, A }, { A, A, A, A, A } } );
2702 // if ( !glm.equals( gl_fitch_d ) ) {
2705 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X }, { X, O, X },
2706 // { O, O, X }, { X, O, X }, { X, O, O }, { O, O, O } } );
2707 // if ( !bsm.equals( i_dollo_bc ) ) {
2710 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, O }, { X, O, O },
2711 // { O, O, O }, { X, O, O }, { X, O, O }, { O, O, O } } );
2712 // if ( !bsm.equals( i_fitch_bc ) ) {
2715 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P }, { L, P, L },
2716 // { P, G, P }, { P, A, L }, { P, A, P }, { A, A, P }, { A, A, L }, { L, A, P }, { P, A, G },
2717 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2718 // if ( !glm.equals( gl_dollo_bc ) ) {
2721 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, G }, { L, P, A },
2722 // { P, G, A }, { P, A, A }, { P, A, A }, { A, A, G }, { A, A, A }, { L, A, A }, { P, A, A },
2723 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2724 // if ( !glm.equals( gl_fitch_bc ) ) {
2728 catch ( final Exception e ) {
2729 e.printStackTrace( System.out );
2735 private static boolean testDirectednessAndAdjacency() {
2737 final Protein one_1 = new BasicProtein( "one", "1", 0 );
2738 final Protein two_1 = new BasicProtein( "two", "1", 0 );
2739 final Protein three_1 = new BasicProtein( "three", "1", 0 );
2740 final Protein four_1 = new BasicProtein( "four", "1", 0 );
2741 final Protein five_1 = new BasicProtein( "five", "1", 0 );
2742 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2743 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2744 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2745 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2746 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2747 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2748 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2749 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2750 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2751 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2752 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2753 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2754 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2755 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2756 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2757 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2758 final List<Protein> list_1 = new ArrayList<Protein>();
2759 list_1.add( one_1 );
2760 list_1.add( two_1 );
2761 list_1.add( three_1 );
2762 list_1.add( four_1 );
2763 list_1.add( five_1 );
2764 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2765 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED_ADJACTANT );
2766 if ( !gwcd_1.toBinaryDomainCombinations()
2767 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "B" ) ) ) {
2770 if ( gwcd_1.toBinaryDomainCombinations()
2771 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "A" ) ) ) {
2774 if ( gwcd_1.toBinaryDomainCombinations()
2775 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "A" ) ) ) {
2778 if ( gwcd_1.toBinaryDomainCombinations()
2779 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "C" ) ) ) {
2782 if ( gwcd_1.toBinaryDomainCombinations()
2783 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "A" ) ) ) {
2786 if ( !gwcd_1.toBinaryDomainCombinations()
2787 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "C" ) ) ) {
2790 if ( !gwcd_1.toBinaryDomainCombinations()
2791 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "X" ) ) ) {
2794 if ( gwcd_1.toBinaryDomainCombinations()
2795 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2798 if ( !gwcd_1.toBinaryDomainCombinations()
2799 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2802 if ( gwcd_1.toBinaryDomainCombinations()
2803 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2806 if ( gwcd_1.toBinaryDomainCombinations()
2807 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2810 if ( !gwcd_1.toBinaryDomainCombinations()
2811 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2814 if ( gwcd_1.toBinaryDomainCombinations()
2815 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "A" ) ) ) {
2818 if ( gwcd_1.toBinaryDomainCombinations()
2819 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "B" ) ) ) {
2822 if ( !gwcd_1.toBinaryDomainCombinations()
2823 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2826 if ( gwcd_1.toBinaryDomainCombinations()
2827 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2830 if ( gwcd_1.toBinaryDomainCombinations()
2831 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2834 if ( gwcd_1.toBinaryDomainCombinations()
2835 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2838 if ( gwcd_1.toBinaryDomainCombinations()
2839 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2842 if ( !gwcd_1.toBinaryDomainCombinations()
2843 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "N" ) ) ) {
2846 if ( !gwcd_1.toBinaryDomainCombinations()
2847 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "M" ) ) ) {
2850 if ( !gwcd_1.toBinaryDomainCombinations()
2851 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "P" ) ) ) {
2854 if ( gwcd_1.toBinaryDomainCombinations()
2855 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "P" ) ) ) {
2858 if ( gwcd_1.toBinaryDomainCombinations()
2859 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "N" ) ) ) {
2862 if ( gwcd_1.toBinaryDomainCombinations()
2863 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "M" ) ) ) {
2866 if ( gwcd_1.toBinaryDomainCombinations()
2867 .contains( new AdjactantDirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2870 if ( gwcd_1.toBinaryDomainCombinations()
2871 .contains( new AdjactantDirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2874 if ( gwcd_1.toBinaryDomainCombinations()
2875 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "B" ) ) ) {
2879 catch ( final Exception e ) {
2880 e.printStackTrace( System.out );
2886 private static boolean testDomainArchitectureBasedGenomeSimilarityCalculator() {
2888 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2889 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2890 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2891 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2892 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2893 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2894 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2895 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2896 final Domain i = new BasicDomain( "i", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2897 final Domain j = new BasicDomain( "j", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2898 final Domain k = new BasicDomain( "k", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2899 final Domain l = new BasicDomain( "l", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2900 final Domain m = new BasicDomain( "m", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2901 final Domain n = new BasicDomain( "n", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2902 final Protein eel_0 = new BasicProtein( "0", "eel", 0 );
2903 final Protein eel_1 = new BasicProtein( "1", "eel", 0 );
2904 final Protein eel_2 = new BasicProtein( "2", "eel", 0 );
2905 final Protein eel_3 = new BasicProtein( "3", "eel", 0 );
2906 final Protein eel_4 = new BasicProtein( "4", "eel", 0 );
2907 final Protein eel_5 = new BasicProtein( "5", "eel", 0 );
2908 final Protein eel_6 = new BasicProtein( "6", "eel", 0 );
2909 final Protein rat_0 = new BasicProtein( "0", "rat", 0 );
2910 final Protein rat_1 = new BasicProtein( "1", "rat", 0 );
2911 final Protein rat_2 = new BasicProtein( "2", "rat", 0 );
2912 final Protein rat_3 = new BasicProtein( "3", "rat", 0 );
2913 final Protein rat_4 = new BasicProtein( "4", "rat", 0 );
2914 final Protein rat_5 = new BasicProtein( "5", "rat", 0 );
2915 final Protein rat_6 = new BasicProtein( "6", "rat", 0 );
2916 final Protein rat_7 = new BasicProtein( "7", "rat", 0 );
2917 eel_1.addProteinDomain( a );
2918 eel_2.addProteinDomain( a );
2919 eel_2.addProteinDomain( b );
2920 eel_3.addProteinDomain( a );
2921 eel_3.addProteinDomain( a );
2922 eel_3.addProteinDomain( b );
2923 eel_4.addProteinDomain( a );
2924 eel_4.addProteinDomain( b );
2925 eel_4.addProteinDomain( c );
2926 eel_4.addProteinDomain( d );
2927 eel_4.addProteinDomain( e );
2928 eel_5.addProteinDomain( e );
2929 eel_5.addProteinDomain( e );
2930 eel_5.addProteinDomain( f );
2931 eel_5.addProteinDomain( f );
2932 eel_5.addProteinDomain( f );
2933 eel_5.addProteinDomain( f );
2934 eel_6.addProteinDomain( g );
2935 eel_6.addProteinDomain( h );
2936 rat_1.addProteinDomain( a );
2937 rat_2.addProteinDomain( a );
2938 rat_2.addProteinDomain( b );
2939 rat_3.addProteinDomain( a );
2940 rat_3.addProteinDomain( a );
2941 rat_3.addProteinDomain( b );
2942 rat_4.addProteinDomain( a );
2943 rat_4.addProteinDomain( b );
2944 rat_4.addProteinDomain( c );
2945 rat_4.addProteinDomain( i );
2946 rat_4.addProteinDomain( l );
2947 rat_5.addProteinDomain( i );
2948 rat_5.addProteinDomain( f );
2949 rat_5.addProteinDomain( f );
2950 rat_6.addProteinDomain( j );
2951 rat_6.addProteinDomain( k );
2952 rat_7.addProteinDomain( m );
2953 rat_7.addProteinDomain( n );
2954 final List<Protein> protein_list_eel = new ArrayList<Protein>();
2955 protein_list_eel.add( eel_0 );
2956 protein_list_eel.add( eel_1 );
2957 protein_list_eel.add( eel_2 );
2958 protein_list_eel.add( eel_3 );
2959 protein_list_eel.add( eel_4 );
2960 protein_list_eel.add( eel_5 );
2961 protein_list_eel.add( eel_6 );
2962 final List<Protein> protein_list_rat = new ArrayList<Protein>();
2963 protein_list_rat.add( rat_0 );
2964 protein_list_rat.add( rat_1 );
2965 protein_list_rat.add( rat_2 );
2966 protein_list_rat.add( rat_3 );
2967 protein_list_rat.add( rat_4 );
2968 protein_list_rat.add( rat_5 );
2969 protein_list_rat.add( rat_6 );
2970 protein_list_rat.add( rat_7 );
2971 final GenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
2972 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
2973 final GenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
2974 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
2975 final GenomeWideCombinableDomains rat_not_ignore = BasicGenomeWideCombinableDomains
2976 .createInstance( protein_list_rat, false, new BasicSpecies( "rat" ) );
2977 final GenomeWideCombinableDomains rat_ignore = BasicGenomeWideCombinableDomains
2978 .createInstance( protein_list_rat, true, new BasicSpecies( "rat" ) );
2979 final DomainArchitectureBasedGenomeSimilarityCalculator calc_ni = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_not_ignore,
2981 final DomainArchitectureBasedGenomeSimilarityCalculator calc_i = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_ignore,
2983 if ( calc_ni.getAllDomains().size() != 14 ) {
2986 if ( calc_i.getAllDomains().size() != 14 ) {
2989 if ( calc_ni.getDomainsSpecificToGenome0().size() != 4 ) {
2992 if ( calc_i.getDomainsSpecificToGenome0().size() != 4 ) {
2995 if ( calc_ni.getDomainsSpecificToGenome1().size() != 6 ) {
2998 if ( calc_i.getDomainsSpecificToGenome1().size() != 6 ) {
3001 if ( calc_i.getSharedDomains().size() != 4 ) {
3004 if ( calc_ni.getSharedDomains().size() != 4 ) {
3007 if ( !calc_ni.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
3010 if ( !calc_ni.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
3013 if ( !calc_ni.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
3016 if ( !calc_ni.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
3019 if ( calc_ni.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
3022 if ( calc_ni.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
3025 if ( !calc_i.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
3028 if ( !calc_i.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
3031 if ( !calc_i.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
3034 if ( !calc_i.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
3037 if ( calc_i.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
3040 if ( calc_i.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
3043 if ( !calc_ni.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
3046 if ( !calc_ni.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
3049 if ( !calc_ni.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
3052 if ( !calc_ni.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
3055 if ( !calc_ni.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
3058 if ( !calc_ni.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
3061 if ( calc_ni.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
3064 if ( calc_ni.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
3067 if ( calc_ni.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
3070 if ( !calc_i.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
3073 if ( !calc_i.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
3076 if ( !calc_i.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
3079 if ( !calc_i.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
3082 if ( !calc_i.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
3085 if ( !calc_i.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
3088 if ( calc_i.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
3091 if ( calc_i.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
3094 if ( calc_i.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
3097 if ( !calc_i.getSharedDomains().contains( a.getDomainId() ) ) {
3100 if ( !calc_i.getSharedDomains().contains( b.getDomainId() ) ) {
3103 if ( !calc_i.getSharedDomains().contains( c.getDomainId() ) ) {
3106 if ( !calc_i.getSharedDomains().contains( f.getDomainId() ) ) {
3109 final Set<DomainId> all = calc_ni.getAllDomains();
3110 if ( !all.contains( a.getDomainId() ) ) {
3113 if ( !all.contains( b.getDomainId() ) ) {
3116 if ( !all.contains( c.getDomainId() ) ) {
3119 if ( !all.contains( d.getDomainId() ) ) {
3122 if ( !all.contains( e.getDomainId() ) ) {
3125 if ( !all.contains( f.getDomainId() ) ) {
3128 if ( !all.contains( g.getDomainId() ) ) {
3131 if ( !all.contains( h.getDomainId() ) ) {
3134 if ( !all.contains( i.getDomainId() ) ) {
3137 if ( !all.contains( l.getDomainId() ) ) {
3140 if ( !all.contains( j.getDomainId() ) ) {
3143 if ( !all.contains( k.getDomainId() ) ) {
3146 if ( !all.contains( m.getDomainId() ) ) {
3149 if ( !all.contains( n.getDomainId() ) ) {
3152 final Set<BinaryDomainCombination> s_0_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome0();
3153 final Set<BinaryDomainCombination> s_0_i = calc_i.getBinaryDomainCombinationsSpecificToGenome0();
3154 final Set<BinaryDomainCombination> s_1_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome1();
3155 final Set<BinaryDomainCombination> s_1_i = calc_i.getBinaryDomainCombinationsSpecificToGenome1();
3156 final Set<BinaryDomainCombination> a_ni = calc_ni.getAllBinaryDomainCombinations();
3157 final Set<BinaryDomainCombination> a_i = calc_i.getAllBinaryDomainCombinations();
3158 final Set<BinaryDomainCombination> shared_ni = calc_ni.getSharedBinaryDomainCombinations();
3159 final Set<BinaryDomainCombination> shared_i = calc_i.getSharedBinaryDomainCombinations();
3160 if ( a_ni.size() != 25 ) {
3163 if ( a_i.size() != 22 ) {
3166 if ( s_0_ni.size() != 10 ) {
3169 if ( s_0_i.size() != 9 ) {
3172 if ( s_1_ni.size() != 10 ) {
3175 if ( s_1_i.size() != 10 ) {
3178 if ( shared_ni.size() != 5 ) {
3181 if ( shared_i.size() != 3 ) {
3184 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3187 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
3190 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3193 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3196 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3199 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3202 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3205 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3208 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3211 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3214 if ( !a_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3217 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3220 if ( !a_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3223 if ( !a_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3226 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3229 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3232 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3235 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3238 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3241 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3244 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3247 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "l" ) ) ) {
3250 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3253 if ( !a_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3256 if ( !a_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3259 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
3262 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "m" ) ) ) {
3265 if ( a_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3268 if ( a_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3271 if ( a_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3274 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3277 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3280 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3283 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3286 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3289 if ( shared_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3292 if ( shared_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
3295 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3298 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
3301 if ( !shared_i.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
3304 if ( shared_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
3307 if ( shared_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3310 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3313 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3316 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3319 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3322 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3325 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3328 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3331 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3334 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3337 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3340 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
3343 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
3346 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
3349 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
3352 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3355 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3358 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3361 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3364 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3367 if ( s_0_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3370 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3373 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3376 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3379 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3382 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3385 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3388 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3391 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3394 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3397 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3400 if ( s_1_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3403 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3406 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3409 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3412 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3415 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3418 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3421 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3424 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3427 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3430 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3433 if ( s_1_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3436 if ( !isEqual( calc_ni.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3437 1.0 - ( 25.0 - 5.0 ) / 25.0 ) ) {
3440 if ( !isEqual( calc_i.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3441 1.0 - ( 22.0 - 3.0 ) / 22.0 ) ) {
3444 if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
3447 if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 14.0 - 4.0 ) / 14.0 ) ) {
3450 final Domain u = new BasicDomain( "u", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3451 final Domain v = new BasicDomain( "v", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3452 final Domain w = new BasicDomain( "w", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3453 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3454 final Domain y = new BasicDomain( "y", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3455 final Domain z = new BasicDomain( "z", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3456 final Protein a_0 = new BasicProtein( "0", "a", 0 );
3457 final Protein a_1 = new BasicProtein( "1", "a", 0 );
3458 final Protein a_2 = new BasicProtein( "2", "a", 0 );
3459 final Protein b_0 = new BasicProtein( "0", "b", 0 );
3460 final Protein b_1 = new BasicProtein( "1", "b", 0 );
3461 a_0.addProteinDomain( u );
3462 a_0.addProteinDomain( v );
3463 a_0.addProteinDomain( w );
3464 a_1.addProteinDomain( w );
3465 a_1.addProteinDomain( x );
3466 a_2.addProteinDomain( y );
3467 a_2.addProteinDomain( z );
3468 b_0.addProteinDomain( u );
3469 b_0.addProteinDomain( w );
3470 b_1.addProteinDomain( y );
3471 b_1.addProteinDomain( z );
3472 final List<Protein> protein_list_a = new ArrayList<Protein>();
3473 protein_list_a.add( a_0 );
3474 protein_list_a.add( a_1 );
3475 protein_list_a.add( a_2 );
3476 final List<Protein> protein_list_b = new ArrayList<Protein>();
3477 protein_list_b.add( b_0 );
3478 protein_list_b.add( b_1 );
3479 final GenomeWideCombinableDomains ca = BasicGenomeWideCombinableDomains
3480 .createInstance( protein_list_a, false, new BasicSpecies( "a" ) );
3481 final GenomeWideCombinableDomains cb = BasicGenomeWideCombinableDomains
3482 .createInstance( protein_list_b, true, new BasicSpecies( "b" ) );
3483 final DomainArchitectureBasedGenomeSimilarityCalculator calc_u = new DomainArchitectureBasedGenomeSimilarityCalculator( ca,
3485 calc_u.setAllowDomainsToBeIgnored( true );
3486 if ( calc_u.getAllDomains().size() != 6 ) {
3489 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3492 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3495 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3498 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3501 if ( calc_u.getSharedDomains().size() != 4 ) {
3504 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3507 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3510 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3513 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3516 if ( calc_u.getAllDomains().size() != 6 ) {
3519 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3522 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3525 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3528 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3531 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3534 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3537 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 3 ) {
3540 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3543 if ( calc_u.getSharedBinaryDomainCombinations().size() != 2 ) {
3546 if ( calc_u.getAllBinaryDomainCombinations().size() != 5 ) {
3549 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3550 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3553 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3554 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3557 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3558 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3561 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3564 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3567 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3570 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3573 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3576 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3579 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3582 calc_u.setAllowDomainsToBeIgnored( true );
3583 calc_u.addDomainIdToIgnore( u.getDomainId() );
3584 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3585 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3586 if ( calc_u.getAllDomains().size() != 5 ) {
3589 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3592 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3595 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3598 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3601 if ( calc_u.getSharedDomains().size() != 3 ) {
3604 if ( calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3607 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3610 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3613 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3616 if ( calc_u.getAllDomains().size() != 5 ) {
3619 if ( calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3622 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3625 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3628 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3631 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3634 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3637 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 2 ) {
3640 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3643 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3646 if ( calc_u.getAllBinaryDomainCombinations().size() != 3 ) {
3649 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3650 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3653 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3654 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3657 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3658 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3661 if ( calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3664 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3667 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3670 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3673 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3676 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3679 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3682 calc_u.setAllowDomainsToBeIgnored( false );
3683 if ( calc_u.getAllDomains().size() != 6 ) {
3687 calc_u.setAllowDomainsToBeIgnored( true );
3688 calc_u.deleteAllDomainIdsToIgnore();
3689 calc_u.addDomainIdToIgnore( new DomainId( "v" ) );
3690 calc_u.addDomainIdToIgnore( new DomainId( "w" ) );
3691 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3692 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3693 if ( calc_u.getAllDomains().size() != 4 ) {
3696 if ( calc_u.getDomainsSpecificToGenome0().size() != 1 ) {
3699 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3702 if ( calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3705 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3708 if ( calc_u.getSharedDomains().size() != 3 ) {
3711 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3714 if ( calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3717 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3720 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3723 if ( calc_u.getAllDomains().size() != 4 ) {
3726 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3729 if ( calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3732 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3735 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3738 if ( calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3741 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3744 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 0 ) {
3747 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3750 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3753 if ( calc_u.getAllBinaryDomainCombinations().size() != 1 ) {
3756 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "y", "z" ) ) ) {
3759 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3762 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3763 1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
3766 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
3769 calc_u.setAllowDomainsToBeIgnored( false );
3770 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3771 1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
3774 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
3777 calc_u.setAllowDomainsToBeIgnored( true );
3778 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3779 1.0 - ( 1.0 - 1.0 ) / 1.0 ) ) {
3782 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 4.0 - 3.0 ) / 4.0 ) ) {
3785 calc_u.deleteAllDomainIdsToIgnore();
3786 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3787 1.0 - ( 5.0 - 2.0 ) / 5.0 ) ) {
3790 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( 6.0 - 4.0 ) / 6.0 ) ) {
3794 catch ( final Exception e ) {
3795 e.printStackTrace( System.out );
3801 private static boolean testDomainCombinationCounting( final File test_dir ) {
3803 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
3804 + ForesterUtil.getFileSeparator() + "hmmpfam_output2" ), "human", "ls" );
3805 parser.setEValueMaximum( 0.2 );
3806 parser.setIgnoreDufs( true );
3807 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
3808 final List<Protein> domain_collections = parser.parse();
3809 final BasicGenomeWideCombinableDomains cdcc = BasicGenomeWideCombinableDomains
3810 .createInstance( domain_collections, false, new BasicSpecies( "human" ) );
3811 CombinableDomains cd = cdcc.get( new DomainId( "A" ) );
3812 if ( cd.getKeyDomainCount() != 9 ) {
3815 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3818 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3821 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 2 ) {
3824 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
3827 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3830 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3833 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3836 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3839 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3842 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3845 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3848 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3851 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3854 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3857 if ( cd.getKeyDomainCount() != 9 ) {
3860 cd = cdcc.get( new DomainId( "B" ) );
3861 if ( cd.getKeyDomainCount() != 12 ) {
3864 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3867 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3870 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 6 ) {
3873 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3876 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3879 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3882 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3885 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3888 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3891 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3894 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3897 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3900 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3903 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3906 if ( cd.getKeyDomainCount() != 12 ) {
3909 cd = cdcc.get( new DomainId( "C" ) );
3910 if ( cd.getKeyDomainCount() != 10 ) {
3913 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3916 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3919 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 4 ) {
3922 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3925 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 2 ) {
3928 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3931 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3934 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3937 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3940 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3943 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 2 ) {
3946 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 2 ) {
3949 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 2 ) {
3952 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3955 cd = cdcc.get( new DomainId( "D" ) );
3956 if ( cd.getKeyDomainCount() != 15 ) {
3959 if ( cd.getKeyDomainProteinsCount() != 6 ) {
3962 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3965 cd = cdcc.get( new DomainId( "E" ) );
3966 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3969 if ( cd.getKeyDomainCount() != 1 ) {
3972 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3975 cd = cdcc.get( new DomainId( "U" ) );
3976 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3979 if ( cd.getKeyDomainCount() != 6 ) {
3982 if ( cd.getKeyDomainProteinsCount() != 3 ) {
3985 cd = cdcc.get( new DomainId( "V" ) );
3986 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3989 if ( cd.getKeyDomainCount() != 3 ) {
3992 if ( cd.getKeyDomainProteinsCount() != 2 ) {
3995 cd = cdcc.get( new DomainId( "W" ) );
3996 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3999 if ( cd.getKeyDomainCount() != 2 ) {
4002 if ( cd.getKeyDomainProteinsCount() != 2 ) {
4005 cd = cdcc.get( new DomainId( "X" ) );
4006 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4009 if ( cd.getKeyDomainCount() != 2 ) {
4012 cd = cdcc.get( new DomainId( "Y" ) );
4013 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4016 cd = cdcc.get( new DomainId( "Z" ) );
4017 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4020 cd = cdcc.get( new DomainId( "NN" ) );
4021 if ( cd.getKeyDomainCount() != 1 ) {
4024 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4027 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4030 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
4033 cd = cdcc.get( new DomainId( "MM" ) );
4034 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4037 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 0 ) {
4040 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
4043 cd = cdcc.get( new DomainId( "OO" ) );
4044 if ( cd.getNumberOfCombinableDomains() != 2 ) {
4047 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
4050 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 1 ) {
4053 cd = cdcc.get( new DomainId( "QQ" ) );
4054 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4057 if ( cd.getKeyDomainCount() != 17 ) {
4060 if ( cd.getKeyDomainProteinsCount() != 4 ) {
4063 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "QQ" ).getDomainId() ) != 3 ) {
4066 cd = cdcc.get( new DomainId( "PP" ) );
4067 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4070 if ( cd.getKeyDomainCount() != 2 ) {
4073 if ( cd.getKeyDomainProteinsCount() != 2 ) {
4076 cd = cdcc.get( new DomainId( "singlet" ) );
4077 if ( cd.getKeyDomainCount() != 1 ) {
4080 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4083 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4086 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "singlet" ).getDomainId() ) != 0 ) {
4089 cd = cdcc.get( new DomainId( "three" ) );
4090 if ( cd.getKeyDomainCount() != 3 ) {
4093 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4096 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4099 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 1 ) {
4102 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
4105 // Ignore combinations with same:
4106 final BasicGenomeWideCombinableDomains cdcc2 = BasicGenomeWideCombinableDomains
4107 .createInstance( domain_collections,
4109 new BasicSpecies( "human" ),
4111 DomainCombinationType.BASIC,
4114 cd = cdcc2.get( new DomainId( "A" ) );
4115 if ( cd.getKeyDomainCount() != 9 ) {
4118 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4121 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4124 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 0 ) {
4127 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
4130 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
4133 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
4136 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
4139 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4142 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4145 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4148 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
4151 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
4154 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
4157 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4160 cd = cdcc2.get( new DomainId( "B" ) );
4161 if ( cd.getKeyDomainCount() != 12 ) {
4164 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4167 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4170 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 6 ) {
4173 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 0 ) {
4176 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 4 ) {
4179 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
4182 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
4185 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4188 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4191 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4194 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
4197 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
4200 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
4203 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4206 cd = cdcc2.get( new DomainId( "C" ) );
4207 if ( cd.getKeyDomainCount() != 10 ) {
4210 if ( cd.getKeyDomainProteinsCount() != 7 ) {
4213 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4216 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 4 ) {
4219 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 4 ) {
4222 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 0 ) {
4225 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
4228 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
4231 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
4234 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
4237 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
4240 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 2 ) {
4243 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 2 ) {
4246 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 2 ) {
4249 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4252 cd = cdcc2.get( new DomainId( "D" ) );
4253 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4256 cd = cdcc2.get( new DomainId( "E" ) );
4257 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4260 if ( cd.getKeyDomainCount() != 1 ) {
4263 cd = cdcc2.get( new DomainId( "U" ) );
4264 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4267 cd = cdcc2.get( new DomainId( "V" ) );
4268 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4271 cd = cdcc2.get( new DomainId( "W" ) );
4272 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4275 cd = cdcc2.get( new DomainId( "X" ) );
4276 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4279 cd = cdcc2.get( new DomainId( "Y" ) );
4280 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4283 cd = cdcc2.get( new DomainId( "Z" ) );
4284 if ( cd.getNumberOfCombinableDomains() != 10 ) {
4287 cd = cdcc2.get( new DomainId( "NN" ) );
4288 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4291 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
4294 cd = cdcc2.get( new DomainId( "MM" ) );
4295 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4298 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 0 ) {
4301 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 1 ) {
4304 cd = cdcc2.get( new DomainId( "OO" ) );
4305 if ( cd.getNumberOfCombinableDomains() != 1 ) {
4308 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 0 ) {
4311 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 1 ) {
4314 cd = cdcc2.get( new DomainId( "QQ" ) );
4315 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4318 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "QQ" ) ) != 0 ) {
4321 cd = cdcc2.get( new DomainId( "singlet" ) );
4322 if ( cd.getKeyDomainCount() != 1 ) {
4325 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4328 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4331 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "singlet" ) ) != 0 ) {
4334 cd = cdcc2.get( new DomainId( "three" ) );
4335 if ( cd.getKeyDomainCount() != 3 ) {
4338 if ( cd.getKeyDomainProteinsCount() != 1 ) {
4341 if ( cd.getNumberOfCombinableDomains() != 0 ) {
4344 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 0 ) {
4347 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
4351 catch ( final Exception e ) {
4352 e.printStackTrace( System.out );
4358 private static boolean testDomainId() {
4360 final DomainId id1 = new DomainId( "a" );
4361 final DomainId id2 = new DomainId( "a" );
4362 final DomainId id3 = new DomainId( "A" );
4363 final DomainId id4 = new DomainId( "b" );
4364 if ( !id1.equals( id1 ) ) {
4367 if ( id1.getId().equals( "x" ) ) {
4370 if ( id1.getId().equals( null ) ) {
4373 if ( !id1.equals( id2 ) ) {
4376 if ( id1.equals( id3 ) ) {
4379 if ( id1.hashCode() != id1.hashCode() ) {
4382 if ( id1.hashCode() != id2.hashCode() ) {
4385 if ( id1.hashCode() == id3.hashCode() ) {
4388 if ( id1.compareTo( id1 ) != 0 ) {
4391 if ( id1.compareTo( id2 ) != 0 ) {
4394 if ( id1.compareTo( id3 ) != 0 ) {
4397 if ( id1.compareTo( id4 ) >= 0 ) {
4400 if ( id4.compareTo( id1 ) <= 0 ) {
4403 if ( !id4.getId().equals( "b" ) ) {
4406 final DomainId id5 = new DomainId( " C " );
4407 if ( !id5.getId().equals( "C" ) ) {
4410 if ( id5.equals( id1 ) ) {
4414 catch ( final Exception e ) {
4415 e.printStackTrace( System.out );
4421 private static boolean testDomainSorting() {
4423 final Domain A = new BasicDomain( "A", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4424 final Domain B = new BasicDomain( "B", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4425 final Domain C = new BasicDomain( "C", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.2, -12 );
4426 final Domain D = new BasicDomain( "D", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.3, -12 );
4427 final Domain E = new BasicDomain( "E", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.4, -12 );
4428 final Domain F = new BasicDomain( "F", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.5, -12 );
4429 final Domain G = new BasicDomain( "G", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.6, -12 );
4430 final Domain H1 = new BasicDomain( "H", ( short ) 100, ( short ) 200, ( short ) 1, ( short ) 5, 0.7, -12 );
4431 final Domain H2 = new BasicDomain( "H", ( short ) 300, ( short ) 400, ( short ) 2, ( short ) 5, 0.7, -12 );
4432 final Domain H3 = new BasicDomain( "H", ( short ) 500, ( short ) 600, ( short ) 3, ( short ) 5, 0.7, -12 );
4433 final Domain H4 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 4, ( short ) 5, 0.7, -12 );
4434 final Domain H5 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4435 final Domain H6 = new BasicDomain( "H",
4442 final Domain H7 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4443 final Domain H8 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 200, 0.7, -12 );
4444 final Protein protein = new BasicProtein( "00", "bat", 0 );
4445 protein.addProteinDomain( H5 );
4446 protein.addProteinDomain( H2 );
4447 protein.addProteinDomain( H7 );
4448 protein.addProteinDomain( H6 );
4449 protein.addProteinDomain( A );
4450 protein.addProteinDomain( G );
4451 protein.addProteinDomain( H4 );
4452 protein.addProteinDomain( D );
4453 protein.addProteinDomain( H1 );
4454 protein.addProteinDomain( C );
4455 protein.addProteinDomain( E );
4456 protein.addProteinDomain( F );
4457 protein.addProteinDomain( B );
4458 protein.addProteinDomain( H3 );
4459 protein.addProteinDomain( H7 );
4460 protein.addProteinDomain( H7 );
4461 protein.addProteinDomain( H8 );
4462 final List<Domain> sorted = SurfacingUtil.sortDomainsWithAscendingConfidenceValues( protein );
4463 if ( sorted.size() != 17 ) {
4466 if ( !sorted.get( 0 ).getDomainId().getId().equals( "A" ) ) {
4469 if ( sorted.get( 0 ).getNumber() != 1 ) {
4472 if ( !sorted.get( 1 ).getDomainId().getId().equals( "B" ) ) {
4475 if ( sorted.get( 1 ).getNumber() != 1 ) {
4478 if ( !sorted.get( 2 ).getDomainId().getId().equals( "C" ) ) {
4481 if ( sorted.get( 2 ).getNumber() != 1 ) {
4484 if ( !sorted.get( 3 ).getDomainId().getId().equals( "D" ) ) {
4487 if ( sorted.get( 3 ).getNumber() != 1 ) {
4490 if ( !sorted.get( 4 ).getDomainId().getId().equals( "E" ) ) {
4493 if ( sorted.get( 4 ).getNumber() != 1 ) {
4496 if ( !sorted.get( 5 ).getDomainId().getId().equals( "F" ) ) {
4499 if ( sorted.get( 5 ).getNumber() != 1 ) {
4502 if ( !sorted.get( 6 ).getDomainId().getId().equals( "G" ) ) {
4505 if ( sorted.get( 6 ).getNumber() != 1 ) {
4508 if ( !sorted.get( 7 ).getDomainId().getId().equals( "H" ) ) {
4511 if ( sorted.get( 7 ).getNumber() != 5 ) {
4514 if ( !sorted.get( 8 ).getDomainId().getId().equals( "H" ) ) {
4517 if ( sorted.get( 8 ).getNumber() != 2 ) {
4520 if ( !sorted.get( 9 ).getDomainId().getId().equals( "H" ) ) {
4523 if ( sorted.get( 9 ).getNumber() != 6 ) {
4526 if ( !sorted.get( 10 ).getDomainId().getId().equals( "H" ) ) {
4529 if ( sorted.get( 10 ).getNumber() != 4 ) {
4532 if ( !sorted.get( 11 ).getDomainId().getId().equals( "H" ) ) {
4535 if ( sorted.get( 11 ).getNumber() != 1 ) {
4538 if ( sorted.get( 11 ).getTotalCount() != 5 ) {
4541 if ( !sorted.get( 12 ).getDomainId().getId().equals( "H" ) ) {
4544 if ( sorted.get( 12 ).getNumber() != 3 ) {
4547 if ( !sorted.get( 13 ).getDomainId().getId().equals( "H7" ) ) {
4550 if ( sorted.get( 13 ).getNumber() != 5 ) {
4553 if ( !sorted.get( 14 ).getDomainId().getId().equals( "H7" ) ) {
4556 if ( sorted.get( 14 ).getNumber() != 5 ) {
4559 if ( !sorted.get( 15 ).getDomainId().getId().equals( "H7" ) ) {
4562 if ( sorted.get( 15 ).getNumber() != 5 ) {
4565 // To check if sorting is stable [as claimed by Sun for
4566 // Collections.sort( List )]
4567 if ( !sorted.get( 16 ).getDomainId().getId().equals( "H7" ) ) {
4570 if ( sorted.get( 16 ).getNumber() != 5 ) {
4573 if ( sorted.get( 16 ).getTotalCount() != 200 ) {
4577 catch ( final Exception e ) {
4578 e.printStackTrace( System.out );
4584 private static boolean testEngulfingOverlapRemoval() {
4586 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4587 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
4588 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
4589 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4590 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4591 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4592 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
4593 final List<Boolean> covered = new ArrayList<Boolean>();
4594 covered.add( true ); // 0
4595 covered.add( false ); // 1
4596 covered.add( true ); // 2
4597 covered.add( false ); // 3
4598 covered.add( true ); // 4
4599 covered.add( true ); // 5
4600 covered.add( false ); // 6
4601 covered.add( true ); // 7
4602 covered.add( true ); // 8
4603 if ( SurfacingUtil.isEngulfed( d0, covered ) ) {
4606 if ( SurfacingUtil.isEngulfed( d1, covered ) ) {
4609 if ( SurfacingUtil.isEngulfed( d2, covered ) ) {
4612 if ( !SurfacingUtil.isEngulfed( d3, covered ) ) {
4615 if ( SurfacingUtil.isEngulfed( d4, covered ) ) {
4618 if ( SurfacingUtil.isEngulfed( d5, covered ) ) {
4621 if ( !SurfacingUtil.isEngulfed( d6, covered ) ) {
4624 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4625 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
4626 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
4627 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
4628 abc.addProteinDomain( a );
4629 abc.addProteinDomain( b );
4630 abc.addProteinDomain( c );
4631 final Protein abc_r1 = SurfacingUtil.removeOverlappingDomains( 3, false, abc );
4632 final Protein abc_r2 = SurfacingUtil.removeOverlappingDomains( 3, true, abc );
4633 if ( abc.getNumberOfProteinDomains() != 3 ) {
4636 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
4639 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
4642 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
4645 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "b" ) ) {
4648 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4649 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
4650 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
4651 final Protein def = new BasicProtein( "def", "nemve", 0 );
4652 def.addProteinDomain( d );
4653 def.addProteinDomain( e );
4654 def.addProteinDomain( f );
4655 final Protein def_r1 = SurfacingUtil.removeOverlappingDomains( 5, false, def );
4656 final Protein def_r2 = SurfacingUtil.removeOverlappingDomains( 5, true, def );
4657 if ( def.getNumberOfProteinDomains() != 3 ) {
4660 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
4663 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
4666 if ( !def_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "d" ) ) {
4669 if ( !def_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "f" ) ) {
4672 if ( !def_r2.getProteinDomain( 2 ).getDomainId().getId().equals( "e" ) ) {
4676 catch ( final Exception e ) {
4677 e.printStackTrace( System.out );
4683 private static boolean testGenomeWideCombinableDomains() {
4685 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4686 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4687 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4688 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4689 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4690 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4691 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4692 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4693 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4694 final Protein eel_0 = new BasicProtein( "0", "eel", 0 );
4695 final Protein eel_1 = new BasicProtein( "1", "eel", 0 );
4696 final Protein eel_2 = new BasicProtein( "2", "eel", 0 );
4697 final Protein eel_3 = new BasicProtein( "3", "eel", 0 );
4698 final Protein eel_4 = new BasicProtein( "4", "eel", 0 );
4699 final Protein eel_5 = new BasicProtein( "5", "eel", 0 );
4700 final Protein eel_6 = new BasicProtein( "6", "eel", 0 );
4701 eel_1.addProteinDomain( a );
4702 eel_2.addProteinDomain( a );
4703 eel_2.addProteinDomain( b );
4704 eel_3.addProteinDomain( a );
4705 eel_3.addProteinDomain( a );
4706 eel_3.addProteinDomain( b );
4707 eel_4.addProteinDomain( a );
4708 eel_4.addProteinDomain( b );
4709 eel_4.addProteinDomain( c );
4710 eel_4.addProteinDomain( d );
4711 eel_4.addProteinDomain( e );
4712 eel_5.addProteinDomain( e );
4713 eel_5.addProteinDomain( e );
4714 eel_5.addProteinDomain( f );
4715 eel_5.addProteinDomain( f );
4716 eel_5.addProteinDomain( f );
4717 eel_5.addProteinDomain( f );
4718 eel_6.addProteinDomain( g );
4719 eel_6.addProteinDomain( h );
4720 final List<Protein> protein_list_eel = new ArrayList<Protein>();
4721 protein_list_eel.add( eel_0 );
4722 protein_list_eel.add( eel_1 );
4723 protein_list_eel.add( eel_2 );
4724 protein_list_eel.add( eel_3 );
4725 protein_list_eel.add( eel_4 );
4726 protein_list_eel.add( eel_5 );
4727 protein_list_eel.add( eel_6 );
4728 final BasicGenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
4729 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
4730 final BasicGenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
4731 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
4732 if ( !eel_not_ignore.contains( new DomainId( "a" ) ) ) {
4735 if ( !eel_not_ignore.contains( new DomainId( "b" ) ) ) {
4738 if ( !eel_not_ignore.contains( new DomainId( "c" ) ) ) {
4741 if ( !eel_not_ignore.contains( new DomainId( "d" ) ) ) {
4744 if ( !eel_not_ignore.contains( new DomainId( "e" ) ) ) {
4747 if ( !eel_not_ignore.contains( new DomainId( "f" ) ) ) {
4750 if ( !eel_not_ignore.contains( new DomainId( "g" ) ) ) {
4753 if ( !eel_not_ignore.contains( new DomainId( "h" ) ) ) {
4756 if ( eel_not_ignore.contains( new DomainId( "x" ) ) ) {
4759 if ( !eel_ignore.contains( new DomainId( "a" ) ) ) {
4762 if ( !eel_ignore.contains( new DomainId( "b" ) ) ) {
4765 if ( !eel_ignore.contains( new DomainId( "c" ) ) ) {
4768 if ( !eel_ignore.contains( new DomainId( "d" ) ) ) {
4771 if ( !eel_ignore.contains( new DomainId( "e" ) ) ) {
4774 if ( !eel_ignore.contains( new DomainId( "f" ) ) ) {
4777 if ( !eel_ignore.contains( new DomainId( "g" ) ) ) {
4780 if ( !eel_ignore.contains( new DomainId( "h" ) ) ) {
4783 if ( eel_ignore.contains( new DomainId( "x" ) ) ) {
4786 if ( eel_not_ignore.getSize() != 8 ) {
4789 if ( eel_ignore.getSize() != 8 ) {
4792 if ( eel_not_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 5 ) {
4795 if ( eel_not_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4798 if ( eel_not_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4801 if ( eel_not_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4804 if ( eel_not_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 6 ) {
4807 if ( eel_not_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 2 ) {
4810 if ( eel_not_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4813 if ( eel_not_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4816 if ( eel_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 4 ) {
4819 if ( eel_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4822 if ( eel_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4825 if ( eel_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4828 if ( eel_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 5 ) {
4831 if ( eel_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 1 ) {
4834 if ( eel_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4837 if ( eel_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4840 if ( eel_not_ignore.getAllDomainIds().size() != 8 ) {
4843 if ( !eel_not_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4846 if ( !eel_not_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4849 if ( !eel_not_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4852 if ( !eel_not_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4855 if ( !eel_not_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4858 if ( !eel_not_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4861 if ( !eel_not_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4864 if ( !eel_not_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4867 if ( eel_not_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4870 if ( eel_ignore.getAllDomainIds().size() != 8 ) {
4873 if ( !eel_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4876 if ( !eel_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4879 if ( !eel_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4882 if ( !eel_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4885 if ( !eel_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4888 if ( !eel_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4891 if ( !eel_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4894 if ( !eel_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4897 if ( eel_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4900 final SortedSet<BinaryDomainCombination> bc0 = eel_not_ignore.toBinaryDomainCombinations();
4901 if ( bc0.size() != 15 ) {
4904 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4907 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4910 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4913 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4916 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4919 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4922 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4925 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4928 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4931 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4934 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
4937 if ( !bc0.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
4940 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
4943 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
4946 if ( !bc0.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
4949 if ( !bc0.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
4952 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
4955 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
4958 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "h" ) ) ) {
4961 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
4964 final SortedSet<BinaryDomainCombination> bc1 = eel_ignore.toBinaryDomainCombinations();
4965 if ( bc1.size() != 12 ) {
4968 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4971 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4974 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4977 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4980 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4983 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4986 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4989 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4992 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4995 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4998 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
5001 if ( !bc1.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
5004 if ( !bc1.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
5007 if ( !bc1.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
5010 if ( bc1.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
5013 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
5016 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
5019 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
5022 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
5025 if ( bc1.contains( new BasicBinaryDomainCombination( "b", "g" ) ) ) {
5029 catch ( final Exception e ) {
5030 e.printStackTrace( System.out );
5036 private static boolean testHmmPfamOutputParser( final File test_dir ) {
5038 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
5039 + ForesterUtil.getFileSeparator() + "hmmpfam_output" ), "human", "ls" );
5040 parser.setEValueMaximum( 0.2 );
5041 parser.setIgnoreDufs( true );
5042 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5043 List<?> domain_collections = null;
5044 domain_collections = parser.parse();
5045 if ( parser.getDomainsEncountered() != 4 ) {
5048 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
5051 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
5054 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
5057 if ( parser.getDomainsStored() != 3 ) {
5060 if ( domain_collections.size() != 1 ) {
5063 final Protein pdc = ( Protein ) domain_collections.get( 0 );
5064 if ( !pdc.getProteinId().equals( new ProteinId( "ENSP00000285681" ) ) ) {
5067 if ( !pdc.getSpecies().getSpeciesId().equals( "human" ) ) {
5070 if ( pdc.getNumberOfProteinDomains() != 3 ) {
5073 if ( !pdc.getAccession().equals( "acc_ENSP00000285681" ) ) {
5078 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
5081 final List<Domain> uba = pdc.getProteinDomains( new DomainId( "UBA" ) );
5082 final List<Domain> uim = pdc.getProteinDomains( new DomainId( "UIM" ) );
5083 final List<Domain> uch = pdc.getProteinDomains( new DomainId( "UCH" ) );
5084 if ( uba.size() != 1 ) {
5087 if ( uim.size() != 2 ) {
5090 if ( uch.size() != 0 ) {
5093 final BasicDomain uim_domain = ( BasicDomain ) uim.get( 1 );
5094 if ( !uim_domain.getDomainId().equals( new DomainId( "UIM" ) ) ) {
5097 if ( uim_domain.getTotalCount() != 2 ) {
5100 final BasicDomain uba_domain = ( BasicDomain ) uba.get( 0 );
5101 if ( !uba_domain.getDomainId().equals( new DomainId( "UBA" ) ) ) {
5104 if ( uba_domain.getNumber() != 1 ) {
5107 if ( uba_domain.getTotalCount() != 1 ) {
5110 if ( uba_domain.getFrom() != 16 ) {
5113 if ( uba_domain.getTo() != 57 ) {
5116 if ( !Test.isEqual( uba_domain.getPerSequenceEvalue(), 0.00084 ) ) {
5119 if ( !Test.isEqual( uba_domain.getPerSequenceScore(), 23.2 ) ) {
5122 final HmmPfamOutputParser parser2 = new HmmPfamOutputParser( new File( test_dir
5123 + ForesterUtil.getFileSeparator() + "hmmpfam_output_short" ), "human", "ls" );
5124 parser2.setEValueMaximum( 0.2 );
5125 parser2.setIgnoreDufs( true );
5126 parser2.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5127 List<Protein> domain_collections2 = null;
5128 domain_collections2 = parser2.parse();
5129 if ( parser2.getDomainsEncountered() != 4 ) {
5132 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
5135 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
5138 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
5141 if ( parser2.getDomainsStored() != 3 ) {
5144 if ( domain_collections2.size() != 1 ) {
5147 final Protein pdc2 = domain_collections2.get( 0 );
5148 if ( !pdc2.getProteinId().getId().equals( "ENSP00000285681" ) ) {
5151 if ( !pdc2.getSpecies().getSpeciesId().equals( "human" ) ) {
5154 if ( !pdc2.getName().equals( "" ) ) {
5157 if ( !pdc2.getAccession().equals( "223" ) ) {
5162 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
5165 if ( pdc2.getNumberOfProteinDomains() != 3 ) {
5168 final List<Domain> uba2 = pdc2.getProteinDomains( new DomainId( "UBA" ) );
5169 final List<Domain> uim2 = pdc2.getProteinDomains( new DomainId( "UIM" ) );
5170 final List<Domain> uch2 = pdc2.getProteinDomains( new DomainId( "UCH" ) );
5171 if ( uba2.size() != 1 ) {
5174 if ( uim2.size() != 2 ) {
5177 if ( uch2.size() != 0 ) {
5180 final BasicDomain uim_domain2 = ( BasicDomain ) uim2.get( 1 );
5181 if ( !uim_domain2.getDomainId().getId().equals( "UIM" ) ) {
5184 if ( uim_domain2.getTotalCount() != 2 ) {
5187 final BasicDomain uba_domain2 = ( BasicDomain ) uba2.get( 0 );
5188 if ( !uba_domain2.getDomainId().getId().equals( "UBA" ) ) {
5191 if ( uba_domain2.getNumber() != 1 ) {
5194 if ( uba_domain2.getTotalCount() != 1 ) {
5197 if ( uba_domain2.getFrom() != 16 ) {
5200 if ( uba_domain2.getTo() != 57 ) {
5203 if ( !Test.isEqual( uba_domain2.getPerSequenceEvalue(), 0.00084 ) ) {
5207 catch ( final Exception e ) {
5208 e.printStackTrace( System.out );
5214 private static boolean testHmmPfamOutputParserWithFilter( final File test_dir ) {
5216 HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator()
5217 + "hmmpfam_output3" ), "human", "ls" );
5218 parser.setEValueMaximum( 0.2 );
5219 parser.setIgnoreDufs( true );
5220 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5221 List<Protein> proteins = null;
5222 proteins = parser.parse();
5223 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5226 if ( proteins.size() != 4 ) {
5230 Set<DomainId> filter = new TreeSet<DomainId>();
5231 filter.add( new DomainId( "beauty" ) );
5232 filter.add( new DomainId( "strange" ) );
5233 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5237 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5238 parser.setEValueMaximum( 0.2 );
5239 parser.setIgnoreDufs( true );
5240 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5242 proteins = parser.parse();
5243 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5246 if ( proteins.size() != 4 ) {
5250 filter = new TreeSet<DomainId>();
5251 filter.add( new DomainId( "beauty" ) );
5252 filter.add( new DomainId( "strange" ) );
5253 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5257 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5258 parser.setEValueMaximum( 0.2 );
5259 parser.setIgnoreDufs( true );
5260 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5262 proteins = parser.parse();
5263 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
5266 if ( proteins.size() != 0 ) {
5270 filter = new TreeSet<DomainId>();
5271 filter.add( new DomainId( "UIM" ) );
5272 filter.add( new DomainId( "A" ) );
5273 filter.add( new DomainId( "C" ) );
5274 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5278 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5279 parser.setEValueMaximum( 0.2 );
5280 parser.setIgnoreDufs( true );
5281 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5283 proteins = parser.parse();
5284 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
5287 if ( proteins.size() != 4 ) {
5291 filter = new TreeSet<DomainId>();
5292 filter.add( new DomainId( "UIM" ) );
5293 filter.add( new DomainId( "A" ) );
5294 filter.add( new DomainId( "C" ) );
5295 filter.add( new DomainId( "X" ) );
5296 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5300 HmmPfamOutputParser.FilterType.NEGATIVE_DOMAIN );
5301 parser.setEValueMaximum( 0.2 );
5302 parser.setIgnoreDufs( true );
5303 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5305 proteins = parser.parse();
5306 if ( parser.getDomainsIgnoredDueToNegativeDomainFilter() != 7 ) {
5309 if ( proteins.size() != 3 ) {
5313 filter = new TreeSet<DomainId>();
5314 filter.add( new DomainId( "UIM" ) );
5315 filter.add( new DomainId( "A" ) );
5316 filter.add( new DomainId( "C" ) );
5317 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5321 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5322 parser.setEValueMaximum( 0.2 );
5323 parser.setIgnoreDufs( true );
5324 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5326 proteins = parser.parse();
5327 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
5330 if ( proteins.size() != 0 ) {
5334 filter = new TreeSet<DomainId>();
5335 filter.add( new DomainId( "UIM" ) );
5336 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5340 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
5341 parser.setEValueMaximum( 0.2 );
5342 parser.setIgnoreDufs( true );
5343 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5345 proteins = parser.parse();
5346 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
5349 if ( parser.getProteinsStored() != 3 ) {
5352 if ( proteins.size() != 3 ) {
5356 filter = new TreeSet<DomainId>();
5357 filter.add( new DomainId( "UIM" ) );
5358 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5362 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5363 parser.setEValueMaximum( 0.2 );
5364 parser.setIgnoreDufs( true );
5365 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5367 proteins = parser.parse();
5368 if ( parser.getProteinsIgnoredDueToFilter() != 3 ) {
5371 if ( parser.getProteinsStored() != 1 ) {
5374 if ( proteins.size() != 1 ) {
5378 filter = new TreeSet<DomainId>();
5379 filter.add( new DomainId( "A" ) );
5380 filter.add( new DomainId( "C" ) );
5381 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
5385 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
5386 parser.setEValueMaximum( 0.2 );
5387 parser.setIgnoreDufs( true );
5388 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
5390 proteins = parser.parse();
5391 if ( parser.getDomainsEncountered() != 11 ) {
5394 if ( parser.getProteinsEncountered() != 4 ) {
5397 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
5400 if ( parser.getProteinsStored() != 3 ) {
5403 if ( proteins.size() != 3 ) {
5407 catch ( final Exception e ) {
5408 e.printStackTrace( System.out );
5414 private static boolean testOverlapRemoval() {
5416 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
5417 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5418 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
5419 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5420 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
5421 final List<Boolean> covered = new ArrayList<Boolean>();
5422 covered.add( true ); // 0
5423 covered.add( false ); // 1
5424 covered.add( true ); // 2
5425 covered.add( false ); // 3
5426 covered.add( true ); // 4
5427 covered.add( true ); // 5
5428 covered.add( false ); // 6
5429 covered.add( true ); // 7
5430 covered.add( true ); // 8
5431 if ( SurfacingUtil.calculateOverlap( d0, covered ) != 3 ) {
5434 if ( SurfacingUtil.calculateOverlap( d1, covered ) != 2 ) {
5437 if ( SurfacingUtil.calculateOverlap( d2, covered ) != 6 ) {
5440 if ( SurfacingUtil.calculateOverlap( d3, covered ) != 0 ) {
5443 if ( SurfacingUtil.calculateOverlap( d4, covered ) != 2 ) {
5446 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.01, 1 );
5447 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5448 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
5449 ab.addProteinDomain( a );
5450 ab.addProteinDomain( b );
5451 final Protein ab_s0 = SurfacingUtil.removeOverlappingDomains( 3, false, ab );
5452 if ( ab.getNumberOfProteinDomains() != 2 ) {
5455 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
5458 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
5461 final Protein ab_s1 = SurfacingUtil.removeOverlappingDomains( 4, false, ab );
5462 if ( ab.getNumberOfProteinDomains() != 2 ) {
5465 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
5468 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
5469 final Domain d = new BasicDomain( "d",
5476 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
5477 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
5478 cde.addProteinDomain( c );
5479 cde.addProteinDomain( d );
5480 cde.addProteinDomain( e );
5481 final Protein cde_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, cde );
5482 if ( cde.getNumberOfProteinDomains() != 3 ) {
5485 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
5488 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5489 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5490 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5491 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
5492 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
5493 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
5494 fghi.addProteinDomain( f );
5495 fghi.addProteinDomain( g );
5496 fghi.addProteinDomain( h );
5497 fghi.addProteinDomain( i );
5498 fghi.addProteinDomain( i );
5499 fghi.addProteinDomain( i );
5500 fghi.addProteinDomain( i2 );
5501 final Protein fghi_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, fghi );
5502 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5505 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
5508 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "h" ) ) {
5511 final Protein fghi_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, fghi );
5512 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5515 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
5518 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5519 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5520 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5521 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
5522 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
5523 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
5524 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5525 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
5526 jklm.addProteinDomain( j );
5527 jklm.addProteinDomain( k );
5528 jklm.addProteinDomain( l );
5529 jklm.addProteinDomain( m );
5530 jklm.addProteinDomain( m0 );
5531 jklm.addProteinDomain( m1 );
5532 jklm.addProteinDomain( m2 );
5533 final Protein jklm_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, jklm );
5534 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5537 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
5540 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "l" ) ) {
5543 final Protein jklm_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, jklm );
5544 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5547 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
5550 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5551 final Protein od = new BasicProtein( "od", "varanus", 0 );
5552 od.addProteinDomain( only );
5553 final Protein od_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, od );
5554 if ( od.getNumberOfProteinDomains() != 1 ) {
5557 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
5561 catch ( final Exception e ) {
5562 e.printStackTrace( System.out );
5568 private static boolean testParsimony() {
5570 final BinaryStates X = BinaryStates.PRESENT;
5571 final BinaryStates O = BinaryStates.ABSENT;
5572 final GainLossStates G = GainLossStates.GAIN;
5573 final GainLossStates L = GainLossStates.LOSS;
5574 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5575 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5576 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5577 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5578 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5579 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5580 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5581 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5582 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5583 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5584 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5585 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5586 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5587 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5588 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5589 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5590 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5591 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5592 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5593 // 1 a-a a-b a-c e-f-g-h l-m
5594 // 2 a-b a-c e-f-g-i n-o
5595 // 3 a-b a-d e-f-g-j p-q
5597 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5598 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5599 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5601 // 1 a b c e f g h l m
5602 // 2 a b c e f g i n o
5603 // 3 a b d e f g j p q
5605 final Protein aa1 = new BasicProtein( "aa1", "one", 0 );
5606 aa1.addProteinDomain( a );
5607 aa1.addProteinDomain( a );
5608 final Protein ab1 = new BasicProtein( "ab1", "one", 0 );
5609 ab1.addProteinDomain( a );
5610 ab1.addProteinDomain( b );
5611 final Protein ac1 = new BasicProtein( "ac1", "one", 0 );
5612 ac1.addProteinDomain( a );
5613 ac1.addProteinDomain( c );
5614 final Protein efgh1 = new BasicProtein( "efgh1", "one", 0 );
5615 efgh1.addProteinDomain( e );
5616 efgh1.addProteinDomain( f );
5617 efgh1.addProteinDomain( g );
5618 efgh1.addProteinDomain( h );
5619 final Protein lm1 = new BasicProtein( "lm1", "one", 0 );
5620 lm1.addProteinDomain( l );
5621 lm1.addProteinDomain( m );
5622 final Protein ab2 = new BasicProtein( "ab2", "two", 0 );
5623 ab2.addProteinDomain( a );
5624 ab2.addProteinDomain( b );
5625 final Protein ac2 = new BasicProtein( "ac2", "two", 0 );
5626 ac2.addProteinDomain( a );
5627 ac2.addProteinDomain( c );
5628 final Protein efgi2 = new BasicProtein( "efgi2", "two", 0 );
5629 efgi2.addProteinDomain( e );
5630 efgi2.addProteinDomain( f );
5631 efgi2.addProteinDomain( g );
5632 efgi2.addProteinDomain( i );
5633 final Protein no2 = new BasicProtein( "no2", "two", 0 );
5634 no2.addProteinDomain( n );
5635 no2.addProteinDomain( o );
5636 final Protein ab3 = new BasicProtein( "ab3", "three", 0 );
5637 ab3.addProteinDomain( a );
5638 ab3.addProteinDomain( b );
5639 final Protein ad3 = new BasicProtein( "ad3", "three", 0 );
5640 ad3.addProteinDomain( a );
5641 ad3.addProteinDomain( d );
5642 final Protein efgj3 = new BasicProtein( "efgj3", "three", 0 );
5643 efgj3.addProteinDomain( e );
5644 efgj3.addProteinDomain( f );
5645 efgj3.addProteinDomain( g );
5646 efgj3.addProteinDomain( j );
5647 final Protein pq3 = new BasicProtein( "pq3", "three", 0 );
5648 pq3.addProteinDomain( p );
5649 pq3.addProteinDomain( q );
5650 final Protein ab4 = new BasicProtein( "ab4", "four", 0 );
5651 ab4.addProteinDomain( a );
5652 ab4.addProteinDomain( b );
5653 final Protein ad4 = new BasicProtein( "ad4", "four", 0 );
5654 ad4.addProteinDomain( a );
5655 ad4.addProteinDomain( d );
5656 final Protein pr4 = new BasicProtein( "pr4", "four", 0 );
5657 pr4.addProteinDomain( p );
5658 pr4.addProteinDomain( r );
5659 final List<Protein> one_list = new ArrayList<Protein>();
5660 one_list.add( aa1 );
5661 one_list.add( ab1 );
5662 one_list.add( ac1 );
5663 one_list.add( efgh1 );
5664 one_list.add( lm1 );
5665 final List<Protein> two_list = new ArrayList<Protein>();
5666 two_list.add( ab2 );
5667 two_list.add( ac2 );
5668 two_list.add( efgi2 );
5669 two_list.add( no2 );
5670 final List<Protein> three_list = new ArrayList<Protein>();
5671 three_list.add( ab3 );
5672 three_list.add( ad3 );
5673 three_list.add( efgj3 );
5674 three_list.add( pq3 );
5675 final List<Protein> four_list = new ArrayList<Protein>();
5676 four_list.add( ab4 );
5677 four_list.add( ad4 );
5678 four_list.add( pr4 );
5679 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5680 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5681 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5682 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5683 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5684 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5685 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5686 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5687 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5688 gwcd_list.add( one );
5689 gwcd_list.add( two );
5690 gwcd_list.add( three );
5691 gwcd_list.add( four );
5692 final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
5693 .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
5694 final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
5695 .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
5696 // 1 a b c e f g h l m
5697 // 2 a b c e f g i n o
5698 // 3 a b d e f g j p q
5700 if ( matrix_d.getState( 0, 0 ) != X ) {
5703 if ( matrix_d.getState( 0, 1 ) != X ) {
5706 if ( matrix_d.getState( 0, 2 ) != X ) {
5709 if ( matrix_d.getState( 0, 3 ) != O ) {
5712 if ( matrix_d.getState( 0, 4 ) != X ) {
5715 if ( matrix_d.getState( 0, 5 ) != X ) {
5718 if ( matrix_d.getState( 0, 6 ) != X ) {
5721 if ( matrix_d.getState( 0, 7 ) != X ) {
5724 if ( matrix_d.getState( 0, 8 ) != O ) {
5727 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5728 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5729 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5731 if ( matrix_bc.getState( 0, 0 ) != X ) {
5734 if ( matrix_bc.getState( 0, 1 ) != X ) {
5737 if ( matrix_bc.getState( 0, 2 ) != X ) {
5740 if ( matrix_bc.getState( 0, 3 ) != O ) {
5743 if ( matrix_bc.getState( 0, 4 ) != X ) {
5746 if ( matrix_bc.getState( 1, 0 ) != O ) {
5749 if ( matrix_bc.getState( 1, 1 ) != X ) {
5752 if ( matrix_bc.getState( 1, 2 ) != X ) {
5755 if ( matrix_bc.getState( 1, 3 ) != O ) {
5758 if ( matrix_bc.getState( 1, 4 ) != X ) {
5761 if ( matrix_bc.getState( 2, 0 ) != O ) {
5764 if ( matrix_bc.getState( 2, 1 ) != X ) {
5767 if ( matrix_bc.getState( 2, 2 ) != O ) {
5770 if ( matrix_bc.getState( 2, 3 ) != X ) {
5773 if ( matrix_bc.getState( 2, 4 ) != X ) {
5776 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
5777 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
5778 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
5779 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list );
5780 dp0.executeDolloParsimonyOnDomainPresence();
5781 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
5782 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
5783 dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
5784 final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
5785 final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
5786 if ( is_matrix_d.getState( "root", "A" ) != X ) {
5789 if ( is_matrix_d.getState( "root", "B" ) != X ) {
5792 if ( is_matrix_d.getState( "root", "C" ) != O ) {
5795 if ( is_matrix_d.getState( "root", "D" ) != O ) {
5798 if ( is_matrix_d.getState( "root", "E" ) != X ) {
5801 if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
5804 if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
5807 if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
5810 if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
5813 if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
5816 if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
5819 if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
5822 if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
5825 if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
5828 if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
5831 if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
5834 if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
5837 if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
5840 if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
5844 catch ( final Exception e ) {
5845 e.printStackTrace( System.out );
5851 private static boolean testParsimonyOnSecondaryFeatures() {
5853 final BinaryStates X = BinaryStates.PRESENT;
5854 final BinaryStates O = BinaryStates.ABSENT;
5855 final GainLossStates G = GainLossStates.GAIN;
5856 final GainLossStates L = GainLossStates.LOSS;
5857 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5858 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5859 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5860 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5861 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5862 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5863 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5864 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5865 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5866 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5867 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5868 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5869 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5870 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5871 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5872 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5873 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5874 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5875 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5876 // 1 a-a a-b a-c e-f-g-h l-m
5877 // 2 a-b a-c e-f-g-i n-o
5878 // 3 a-b a-d e-f-g-j p-q
5880 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5881 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5882 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5884 // 1 a b c e f g h l m
5885 // 2 a b c e f g i n o
5886 // 3 a b d e f g j p q
5888 final Protein aa1 = new BasicProtein( "aa1", "one", 0 );
5889 aa1.addProteinDomain( a );
5890 aa1.addProteinDomain( a );
5891 final Protein ab1 = new BasicProtein( "ab1", "one", 0 );
5892 ab1.addProteinDomain( a );
5893 ab1.addProteinDomain( b );
5894 final Protein ac1 = new BasicProtein( "ac1", "one", 0 );
5895 ac1.addProteinDomain( a );
5896 ac1.addProteinDomain( c );
5897 final Protein efgh1 = new BasicProtein( "efgh1", "one", 0 );
5898 efgh1.addProteinDomain( e );
5899 efgh1.addProteinDomain( f );
5900 efgh1.addProteinDomain( g );
5901 efgh1.addProteinDomain( h );
5902 final Protein lm1 = new BasicProtein( "lm1", "one", 0 );
5903 lm1.addProteinDomain( l );
5904 lm1.addProteinDomain( m );
5905 final Protein ab2 = new BasicProtein( "ab2", "two", 0 );
5906 ab2.addProteinDomain( a );
5907 ab2.addProteinDomain( b );
5908 final Protein ac2 = new BasicProtein( "ac2", "two", 0 );
5909 ac2.addProteinDomain( a );
5910 ac2.addProteinDomain( c );
5911 final Protein efgi2 = new BasicProtein( "efgi2", "two", 0 );
5912 efgi2.addProteinDomain( e );
5913 efgi2.addProteinDomain( f );
5914 efgi2.addProteinDomain( g );
5915 efgi2.addProteinDomain( i );
5916 final Protein no2 = new BasicProtein( "no2", "two", 0 );
5917 no2.addProteinDomain( n );
5918 no2.addProteinDomain( o );
5919 final Protein ab3 = new BasicProtein( "ab3", "three", 0 );
5920 ab3.addProteinDomain( a );
5921 ab3.addProteinDomain( b );
5922 final Protein ad3 = new BasicProtein( "ad3", "three", 0 );
5923 ad3.addProteinDomain( a );
5924 ad3.addProteinDomain( d );
5925 final Protein efgj3 = new BasicProtein( "efgj3", "three", 0 );
5926 efgj3.addProteinDomain( e );
5927 efgj3.addProteinDomain( f );
5928 efgj3.addProteinDomain( g );
5929 efgj3.addProteinDomain( j );
5930 final Protein pq3 = new BasicProtein( "pq3", "three", 0 );
5931 pq3.addProteinDomain( p );
5932 pq3.addProteinDomain( q );
5933 final Protein ab4 = new BasicProtein( "ab4", "four", 0 );
5934 ab4.addProteinDomain( a );
5935 ab4.addProteinDomain( b );
5936 final Protein ad4 = new BasicProtein( "ad4", "four", 0 );
5937 ad4.addProteinDomain( a );
5938 ad4.addProteinDomain( d );
5939 final Protein pr4 = new BasicProtein( "pr4", "four", 0 );
5940 pr4.addProteinDomain( p );
5941 pr4.addProteinDomain( r );
5942 final List<Protein> one_list = new ArrayList<Protein>();
5943 one_list.add( aa1 );
5944 one_list.add( ab1 );
5945 one_list.add( ac1 );
5946 one_list.add( efgh1 );
5947 one_list.add( lm1 );
5948 final List<Protein> two_list = new ArrayList<Protein>();
5949 two_list.add( ab2 );
5950 two_list.add( ac2 );
5951 two_list.add( efgi2 );
5952 two_list.add( no2 );
5953 final List<Protein> three_list = new ArrayList<Protein>();
5954 three_list.add( ab3 );
5955 three_list.add( ad3 );
5956 three_list.add( efgj3 );
5957 three_list.add( pq3 );
5958 final List<Protein> four_list = new ArrayList<Protein>();
5959 four_list.add( ab4 );
5960 four_list.add( ad4 );
5961 four_list.add( pr4 );
5962 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5963 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5964 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5965 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5966 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5967 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5968 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5969 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5970 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5971 gwcd_list.add( one );
5972 gwcd_list.add( two );
5973 gwcd_list.add( three );
5974 gwcd_list.add( four );
5975 final Map<DomainId, Set<String>> map_same = new HashMap<DomainId, Set<String>>();
5976 final HashSet<String> a_s = new HashSet<String>();
5978 final HashSet<String> b_s = new HashSet<String>();
5980 final HashSet<String> c_s = new HashSet<String>();
5982 final HashSet<String> d_s = new HashSet<String>();
5984 final HashSet<String> e_s = new HashSet<String>();
5986 final HashSet<String> f_s = new HashSet<String>();
5988 final HashSet<String> g_s = new HashSet<String>();
5990 final HashSet<String> h_s = new HashSet<String>();
5992 final HashSet<String> i_s = new HashSet<String>();
5994 final HashSet<String> j_s = new HashSet<String>();
5996 final HashSet<String> l_s = new HashSet<String>();
5998 final HashSet<String> m_s = new HashSet<String>();
6000 final HashSet<String> n_s = new HashSet<String>();
6002 final HashSet<String> o_s = new HashSet<String>();
6004 final HashSet<String> p_s = new HashSet<String>();
6006 final HashSet<String> q_s = new HashSet<String>();
6008 final HashSet<String> r_s = new HashSet<String>();
6010 map_same.put( a.getDomainId(), a_s );
6011 map_same.put( b.getDomainId(), b_s );
6012 map_same.put( c.getDomainId(), c_s );
6013 map_same.put( d.getDomainId(), d_s );
6014 map_same.put( e.getDomainId(), e_s );
6015 map_same.put( f.getDomainId(), f_s );
6016 map_same.put( g.getDomainId(), g_s );
6017 map_same.put( h.getDomainId(), h_s );
6018 map_same.put( i.getDomainId(), i_s );
6019 map_same.put( j.getDomainId(), j_s );
6020 map_same.put( l.getDomainId(), l_s );
6021 map_same.put( m.getDomainId(), m_s );
6022 map_same.put( n.getDomainId(), n_s );
6023 map_same.put( o.getDomainId(), o_s );
6024 map_same.put( p.getDomainId(), p_s );
6025 map_same.put( q.getDomainId(), q_s );
6026 map_same.put( r.getDomainId(), r_s );
6027 final CharacterStateMatrix<BinaryStates> matrix_s = DomainParsimonyCalculator
6028 .createMatrixOfSecondaryFeaturePresenceOrAbsence( gwcd_list, map_same, null );
6029 // 1 a b c e f g h l m
6030 // 2 a b c e f g i n o
6031 // 3 a b d e f g j p q
6033 if ( matrix_s.getState( 0, 0 ) != X ) {
6036 if ( matrix_s.getState( 0, 1 ) != X ) {
6039 if ( matrix_s.getState( 0, 2 ) != X ) {
6042 if ( matrix_s.getState( 0, 3 ) != O ) {
6045 if ( matrix_s.getState( 0, 4 ) != X ) {
6048 if ( matrix_s.getState( 0, 5 ) != X ) {
6051 if ( matrix_s.getState( 0, 6 ) != X ) {
6054 if ( matrix_s.getState( 0, 7 ) != X ) {
6057 if ( matrix_s.getState( 0, 8 ) != O ) {
6060 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
6061 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
6062 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
6063 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list, map_same );
6064 dp0.executeDolloParsimonyOnSecondaryFeatures( null );
6065 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
6066 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
6067 if ( is_matrix_d.getState( "root", "AAA" ) != X ) {
6070 if ( is_matrix_d.getState( "root", "BBB" ) != X ) {
6073 if ( is_matrix_d.getState( "root", "CCC" ) != O ) {
6076 if ( is_matrix_d.getState( "root", "DDD" ) != O ) {
6079 if ( is_matrix_d.getState( "root", "EEE" ) != X ) {
6082 if ( gl_matrix_d.getState( "3-4", "PPP" ) != G ) {
6086 catch ( final Exception e ) {
6087 e.printStackTrace( System.out );
6093 private static boolean testPaupLogParser( final File test_dir ) {
6095 final PaupLogParser parser = new PaupLogParser();
6096 parser.setSource( new File( test_dir + ForesterUtil.getFileSeparator() + "paup_log_test_1" ) );
6097 final CharacterStateMatrix<BinaryStates> matrix = parser.parse();
6098 if ( matrix.getNumberOfIdentifiers() != 8 ) {
6101 if ( !matrix.getIdentifier( 0 ).equals( "MOUSE" ) ) {
6104 if ( !matrix.getIdentifier( 1 ).equals( "NEMVE" ) ) {
6107 if ( !matrix.getIdentifier( 2 ).equals( "MONBE" ) ) {
6110 if ( !matrix.getIdentifier( 3 ).equals( "DICDI" ) ) {
6113 if ( !matrix.getIdentifier( 4 ).equals( "ARATH" ) ) {
6116 if ( !matrix.getIdentifier( 5 ).equals( "6" ) ) {
6119 if ( !matrix.getIdentifier( 6 ).equals( "7" ) ) {
6122 if ( !matrix.getIdentifier( 7 ).equals( "8" ) ) {
6125 if ( matrix.getNumberOfCharacters() != ( 66 + 66 + 28 ) ) {
6128 if ( matrix.getState( 0, 4 ) != BinaryStates.ABSENT ) {
6131 if ( matrix.getState( 0, 5 ) != BinaryStates.PRESENT ) {
6134 if ( matrix.getState( 1, 5 ) != BinaryStates.PRESENT ) {
6137 if ( matrix.getState( 7, 154 ) != BinaryStates.ABSENT ) {
6140 if ( matrix.getState( 7, 155 ) != BinaryStates.PRESENT ) {
6143 if ( matrix.getState( 7, 156 ) != BinaryStates.PRESENT ) {
6146 if ( matrix.getState( 7, 157 ) != BinaryStates.ABSENT ) {
6149 if ( matrix.getState( 7, 158 ) != BinaryStates.PRESENT ) {
6152 if ( matrix.getState( 7, 159 ) != BinaryStates.ABSENT ) {
6156 catch ( final Exception e ) {
6157 e.printStackTrace( System.out );
6163 private static boolean testProteinId() {
6165 final ProteinId id1 = new ProteinId( "a" );
6166 final ProteinId id2 = new ProteinId( "a" );
6167 final ProteinId id3 = new ProteinId( "A" );
6168 final ProteinId id4 = new ProteinId( "b" );
6169 if ( !id1.equals( id1 ) ) {
6172 if ( id1.getId().equals( "x" ) ) {
6175 if ( id1.getId().equals( null ) ) {
6178 if ( !id1.equals( id2 ) ) {
6181 if ( id1.equals( id3 ) ) {
6184 if ( id1.hashCode() != id1.hashCode() ) {
6187 if ( id1.hashCode() != id2.hashCode() ) {
6190 if ( id1.hashCode() == id3.hashCode() ) {
6193 if ( id1.compareTo( id1 ) != 0 ) {
6196 if ( id1.compareTo( id2 ) != 0 ) {
6199 if ( id1.compareTo( id3 ) != 0 ) {
6202 if ( id1.compareTo( id4 ) >= 0 ) {
6205 if ( id4.compareTo( id1 ) <= 0 ) {
6208 if ( !id4.getId().equals( "b" ) ) {
6211 final ProteinId id5 = new ProteinId( " C " );
6212 if ( !id5.getId().equals( "C" ) ) {
6215 if ( id5.equals( id1 ) ) {
6219 catch ( final Exception e ) {
6220 e.printStackTrace( System.out );
6226 private static boolean testSpecies() {
6228 final Species s1 = new BasicSpecies( "a" );
6229 final Species s2 = new BasicSpecies( "a" );
6230 final Species s3 = new BasicSpecies( "A" );
6231 final Species s4 = new BasicSpecies( "b" );
6232 if ( !s1.equals( s1 ) ) {
6235 if ( s1.getSpeciesId().equals( "x" ) ) {
6238 if ( s1.getSpeciesId().equals( null ) ) {
6241 if ( !s1.equals( s2 ) ) {
6244 if ( s1.equals( s3 ) ) {
6247 if ( s1.hashCode() != s1.hashCode() ) {
6250 if ( s1.hashCode() != s2.hashCode() ) {
6253 if ( s1.hashCode() == s3.hashCode() ) {
6256 if ( s1.compareTo( s1 ) != 0 ) {
6259 if ( s1.compareTo( s2 ) != 0 ) {
6262 if ( s1.compareTo( s3 ) != 0 ) {
6265 if ( s1.compareTo( s4 ) >= 0 ) {
6268 if ( s4.compareTo( s1 ) <= 0 ) {
6271 if ( !s4.getSpeciesId().equals( "b" ) ) {
6274 final Species s5 = new BasicSpecies( " C " );
6275 if ( !s5.getSpeciesId().equals( "C" ) ) {
6278 if ( s5.equals( s1 ) ) {
6282 catch ( final Exception e ) {
6283 e.printStackTrace( System.out );