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: https://sites.google.com/site/cmzmasek/home/software/forester
27 package org.forester.surfacing;
30 import java.util.ArrayList;
31 import java.util.HashMap;
32 import java.util.HashSet;
33 import java.util.Iterator;
34 import java.util.List;
37 import java.util.SortedSet;
38 import java.util.TreeSet;
40 import org.forester.evoinference.matrix.character.BasicCharacterStateMatrix;
41 import org.forester.evoinference.matrix.character.CharacterStateMatrix;
42 import org.forester.evoinference.matrix.character.CharacterStateMatrix.BinaryStates;
43 import org.forester.evoinference.matrix.character.CharacterStateMatrix.GainLossStates;
44 import org.forester.io.parsers.HmmPfamOutputParser;
45 import org.forester.io.parsers.nexus.PaupLogParser;
46 import org.forester.io.parsers.nhx.NHXParser;
47 import org.forester.phylogeny.Phylogeny;
48 import org.forester.phylogeny.PhylogenyNode;
49 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
50 import org.forester.phylogeny.factories.PhylogenyFactory;
51 import org.forester.protein.BasicDomain;
52 import org.forester.protein.BasicProtein;
53 import org.forester.protein.BinaryDomainCombination;
54 import org.forester.protein.BinaryDomainCombination.DomainCombinationType;
55 import org.forester.protein.Domain;
56 import org.forester.protein.DomainId;
57 import org.forester.protein.Protein;
58 import org.forester.protein.ProteinId;
59 import org.forester.species.BasicSpecies;
60 import org.forester.species.Species;
61 import org.forester.test.Test;
62 import org.forester.util.ForesterUtil;
64 @SuppressWarnings( "unused")
65 public class TestSurfacing {
67 private final static double ZERO_DIFF = 1.0E-9;
69 public static boolean isEqual( final double a, final double b ) {
70 return ( ( Math.abs( a - b ) ) < TestSurfacing.ZERO_DIFF );
73 public static boolean test( final File test_dir ) {
74 System.out.print( " Combinable domains: " );
75 if ( !TestSurfacing.testCombinableDomains() ) {
76 System.out.println( "failed." );
79 System.out.println( "OK." );
80 System.out.print( " Directed combinable domains: " );
81 if ( !TestSurfacing.testDirectedCombinableDomains() ) {
82 System.out.println( "failed." );
85 System.out.println( "OK." );
86 System.out.print( " Genome wide specific combinable domains: " );
87 if ( !TestSurfacing.testGenomeWideCombinableDomains() ) {
88 System.out.println( "failed." );
91 System.out.println( "OK." );
92 System.out.print( " Domain architecture based genome similarity calculator: " );
93 if ( !TestSurfacing.testDomainArchitectureBasedGenomeSimilarityCalculator() ) {
94 System.out.println( "failed." );
97 System.out.println( "OK." );
98 System.out.print( " Hmmpfam output parser: " );
99 if ( !TestSurfacing.testHmmPfamOutputParser( test_dir ) ) {
100 System.out.println( "failed." );
103 System.out.println( "OK." );
104 System.out.print( " Hmmpfam output parser with filter: " );
105 if ( !TestSurfacing.testHmmPfamOutputParserWithFilter( test_dir ) ) {
106 System.out.println( "failed." );
109 System.out.println( "OK." );
110 System.out.print( " Combinations based pairwise similarity calculator: " );
111 if ( !TestSurfacing.testCombinationsBasedPairwiseSimilarityCalculator() ) {
112 System.out.println( "failed." );
115 System.out.println( "OK." );
116 System.out.print( " Copy number based pairwise similarity calculator: " );
117 if ( !TestSurfacing.testCopyNumberBasedPairwiseSimilarityCalculator() ) {
120 System.out.println( "OK." );
121 System.out.print( " Domain combination counting: " );
122 if ( !TestSurfacing.testDomainCombinationCounting( test_dir ) ) {
123 System.out.println( "failed." );
126 System.out.println( "OK." );
127 System.out.print( " Basic domain similarity calculator: " );
128 if ( !TestSurfacing.testBasicDomainSimilarityCalculator() ) {
129 System.out.println( "failed." );
132 System.out.println( "OK." );
133 System.out.print( " Basic domain similarity calculator not ignoring species specific domains: " );
134 if ( !TestSurfacing.testBasicDomainSimilarityCalculatorNotIgnoringSpeciesSpeficDomains() ) {
135 System.out.println( "failed." );
138 System.out.println( "OK." );
139 System.out.print( " Basic domain similarity calculator removal of singles: " );
140 if ( !TestSurfacing.testBasicDomainSimilarityCalculatorRemovalOfSingles() ) {
141 System.out.println( "failed." );
144 System.out.println( "OK." );
145 System.out.print( " Domain sorting: " );
146 if ( !TestSurfacing.testDomainSorting() ) {
147 System.out.println( "failed." );
150 System.out.println( "OK." );
151 System.out.print( " Overlap removal: " );
152 if ( !TestSurfacing.testOverlapRemoval() ) {
153 System.out.println( "failed." );
156 System.out.println( "OK." );
157 System.out.print( " Engulfing overlap removal: " );
158 if ( !TestSurfacing.testEngulfingOverlapRemoval() ) {
159 System.out.println( "failed." );
162 System.out.println( "OK." );
163 System.out.print( " Binary domain combination: " );
164 if ( !TestSurfacing.testBinaryDomainCombination() ) {
165 System.out.println( "failed." );
168 System.out.println( "OK." );
169 System.out.print( " Parsimony: " );
170 if ( !TestSurfacing.testParsimony() ) {
171 System.out.println( "failed." );
174 System.out.println( "OK." );
175 System.out.print( " Directedness: " );
176 if ( !TestSurfacing.testDirectedness() ) {
177 System.out.println( "failed." );
180 System.out.println( "OK." );
181 System.out.print( " Directedness and adjacency: " );
182 if ( !TestSurfacing.testDirectednessAndAdjacency() ) {
183 System.out.println( "failed." );
186 System.out.println( "OK." );
187 System.out.print( " Dollo parsimony on secodary features: " );
188 if ( !TestSurfacing.testParsimonyOnSecondaryFeatures() ) {
189 System.out.println( "failed." );
192 System.out.println( "OK." );
193 System.out.print( " Paup log parser: " );
194 if ( !TestSurfacing.testPaupLogParser( test_dir ) ) {
195 System.out.println( "failed." );
198 System.out.println( "OK." );
199 System.out.print( " Binary state matrix to gain loss matrix: " );
200 if ( !TestSurfacing.testBinaryStateMatrixToGainLossMatrix( test_dir ) ) {
201 System.out.println( "failed." );
204 System.out.println( "OK." );
208 private static StringBuffer mapToStringBuffer( final Map<PhylogenyNode, CharacterStateMatrix.BinaryStates> map ) {
209 final StringBuffer sb = new StringBuffer();
210 for( final PhylogenyNode key : map.keySet() ) {
211 if ( !key.isExternal() ) {
212 sb.append( key.getName() );
214 sb.append( map.get( key ).toString() );
215 sb.append( ForesterUtil.getLineSeparator() );
221 private static boolean testBasicDomainSimilarityCalculator() {
229 // m 2/(2+3) 0 4/(4+2)
234 // mean = ( 2/5 + 0 + 2/3 + 1/5 + 1/2 + 2/7 ) / 6
254 // m - 2/(2+3) 4/(4+2)
258 // mean = (2/5 + 2/3 + 1/2)/3 =
264 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
265 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
266 final Domain C = new BasicDomain( "C", 1, 2, ( short ) 1, ( short ) 1, 0.3, -12 );
267 final Domain D = new BasicDomain( "D", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
268 final Domain E = new BasicDomain( "E", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
269 final Domain F = new BasicDomain( "F", 1, 2, ( short ) 1, ( short ) 1, 0.01, -12 );
270 final Domain G = new BasicDomain( "G", 1, 2, ( short ) 1, ( short ) 1, 0.001, -12 );
271 final Domain X = new BasicDomain( "X", 1, 2, ( short ) 1, ( short ) 1, 0.0001, -12 );
272 if ( !TestSurfacing.isEqual( X.getPerSequenceScore(), -12 ) ) {
275 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
276 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
277 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
278 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
279 mouse_1.addProteinDomain( A );
280 mouse_1.addProteinDomain( B );
281 mouse_1.addProteinDomain( C );
282 mouse_1.addProteinDomain( D );
283 mouse_1.addProteinDomain( E );
284 rabbit_1.addProteinDomain( A );
285 rabbit_1.addProteinDomain( C );
286 rabbit_1.addProteinDomain( E );
287 rabbit_1.addProteinDomain( F );
288 rabbit_1.addProteinDomain( F );
289 rabbit_1.addProteinDomain( F );
290 rabbit_1.addProteinDomain( F );
291 rabbit_1.addProteinDomain( F );
292 rabbit_1.addProteinDomain( F );
293 ciona_1.addProteinDomain( A );
294 ciona_1.addProteinDomain( A );
295 ciona_1.addProteinDomain( A );
296 ciona_1.addProteinDomain( A );
297 ciona_1.addProteinDomain( A );
298 ciona_1.addProteinDomain( F );
299 ciona_1.addProteinDomain( G );
300 ciona_1.addProteinDomain( X );
301 nemve_1.addProteinDomain( A );
302 nemve_1.addProteinDomain( B );
303 nemve_1.addProteinDomain( C );
304 nemve_1.addProteinDomain( D );
305 nemve_1.addProteinDomain( E );
306 nemve_1.addProteinDomain( F );
307 nemve_1.addProteinDomain( G );
308 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
309 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
310 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
311 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
312 protein_list_mouse.add( mouse_1 );
313 protein_list_rabbit.add( rabbit_1 );
314 protein_list_ciona.add( ciona_1 );
315 protein_list_nemve.add( nemve_1 );
316 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
317 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
319 new BasicSpecies( "mouse" ) ) );
320 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
322 new BasicSpecies( "rabbit" ) ) );
323 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
325 new BasicSpecies( "ciona" ) ) );
326 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
328 new BasicSpecies( "nemve" ) ) );
329 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
332 final SortedSet<DomainSimilarity> sims = calc
333 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
337 final Iterator<DomainSimilarity> sims_it = sims.iterator();
338 final DomainSimilarity sa = sims_it.next();
339 if ( !sa.getDomainId().getId().equals( "A" ) ) {
342 if ( sa.getSpeciesData().size() != 4 ) {
345 if ( !sa.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
348 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
351 if ( !sa.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
354 if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
357 if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + 0 + ( 2.0 / 3 ) + ( 1.0 / 5 )
358 + ( 1.0 / 2 ) + ( 2.0 / 7 ) ) / 6 ) ) {
361 if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), ( 0.23410788192183737 ) ) ) {
364 if ( !TestSurfacing.isEqual( sa.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
367 if ( !TestSurfacing.isEqual( sa.getMinimalSimilarityScore(), ( 0.0 ) ) ) {
370 if ( sa.getN() != 6 ) {
373 if ( sa.getMaximalDifference() != 7 ) {
376 if ( sa.getMaximalDifferenceInCounts() != 3 ) {
379 final DomainSimilarity sb = sims_it.next();
380 if ( !sb.getDomainId().getId().equals( "B" ) ) {
383 if ( sb.getSpeciesData().size() != 2 ) {
386 if ( !sb.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
389 if ( !sb.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
392 if ( !TestSurfacing.isEqual( sb.getMeanSimilarityScore(), 2.0 / 3 ) ) {
395 if ( !TestSurfacing.isEqual( sb.getStandardDeviationOfSimilarityScore(), 0.0 ) ) {
398 if ( !TestSurfacing.isEqual( sb.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
401 if ( !TestSurfacing.isEqual( sb.getMinimalSimilarityScore(), ( 2.0 / 3 ) ) ) {
404 if ( sb.getN() != 1 ) {
407 if ( sb.getMaximalDifference() != 2 ) {
410 if ( sb.getMaximalDifferenceInCounts() != 2 ) {
413 final DomainSimilarity sc = sims_it.next();
414 if ( !sc.getDomainId().getId().equals( "C" ) ) {
417 if ( sc.getSpeciesData().size() != 3 ) {
420 if ( !sc.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
423 if ( !sc.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
426 if ( !sc.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
429 if ( !TestSurfacing.isEqual( sc.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + ( 2.0 / 3 ) + ( 1.0 / 2 ) ) / 3 ) ) {
432 if ( !TestSurfacing.isEqual( sc.getStandardDeviationOfSimilarityScore(), 0.13471506281091264 ) ) {
435 if ( !TestSurfacing.isEqual( sc.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
438 if ( !TestSurfacing.isEqual( sc.getMinimalSimilarityScore(), ( 2.0 / 5 ) ) ) {
441 if ( sc.getN() != 3 ) {
444 if ( sc.getMaximalDifference() != 3 ) {
447 if ( sc.getMaximalDifferenceInCounts() != 3 ) {
450 // mouse : ....ABCDE.....
451 // rabbit: ....A.C.EFFF..
452 // ciona : AAAAA......FGX
453 // nemve : ....ABCDEFG...
457 // m 2/(2+3) 0 4/(4+2)
458 // r - 1/(1+5) 3/(3+3)
462 // mean = ( 2/5 + 0 + 2/3 + 1/6 + 1/2 + 2/8 ) / 6
466 final List<GenomeWideCombinableDomains> cdc_list2 = new ArrayList<GenomeWideCombinableDomains>();
467 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
469 new BasicSpecies( "mouse" ) ) );
470 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
472 new BasicSpecies( "rabbit" ) ) );
473 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
475 new BasicSpecies( "ciona" ) ) );
476 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
478 new BasicSpecies( "nemve" ) ) );
479 final DomainSimilarityCalculator calc2 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
482 final SortedSet<DomainSimilarity> sims2 = calc2
483 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
487 final Iterator<DomainSimilarity> sims_it2 = sims2.iterator();
488 final DomainSimilarity sa2 = sims_it2.next();
489 if ( !sa2.getDomainId().getId().equals( "A" ) ) {
492 if ( sa2.getSpeciesData().size() != 4 ) {
495 if ( !sa2.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
498 if ( !sa2.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
501 if ( !sa2.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
504 if ( !sa2.getSpeciesData().keySet().contains( new BasicSpecies( "rabbit" ) ) ) {
507 if ( !TestSurfacing.isEqual( sa2.getMeanSimilarityScore(), ( ( 2.0 / 5 ) + 0 + ( 2.0 / 3 ) + ( 1.0 / 6 )
508 + ( 1.0 / 2 ) + ( 2.0 / 8 ) ) / 6 ) ) {
511 if ( !TestSurfacing.isEqual( sa2.getStandardDeviationOfSimilarityScore(), ( 0.2404663678647683 ) ) ) {
514 if ( !TestSurfacing.isEqual( sa2.getMaximalSimilarityScore(), ( 2.0 / 3 ) ) ) {
517 if ( !TestSurfacing.isEqual( sa2.getMinimalSimilarityScore(), ( 0.0 ) ) ) {
520 if ( sa2.getN() != 6 ) {
523 if ( sa2.getMaximalDifference() != 8 ) {
526 if ( sa2.getMaximalDifferenceInCounts() != 3 ) {
529 final Protein ciona_2 = new BasicProtein( "2", "ciona", 0 );
530 ciona_2.addProteinDomain( A );
531 ciona_2.addProteinDomain( A );
532 ciona_2.addProteinDomain( A );
533 ciona_2.addProteinDomain( B );
534 ciona_2.addProteinDomain( B );
535 ciona_2.addProteinDomain( B );
536 ciona_2.addProteinDomain( F );
537 ciona_2.addProteinDomain( F );
538 ciona_2.addProteinDomain( F );
539 ciona_2.addProteinDomain( F );
540 ciona_2.addProteinDomain( G );
541 ciona_2.addProteinDomain( X );
542 final Protein ciona_3 = new BasicProtein( "3", "ciona", 0 );
543 ciona_3.addProteinDomain( A );
544 ciona_3.addProteinDomain( A );
545 ciona_3.addProteinDomain( A );
546 ciona_3.addProteinDomain( A );
547 ciona_3.addProteinDomain( B );
548 ciona_3.addProteinDomain( B );
549 ciona_3.addProteinDomain( X );
550 ciona_3.addProteinDomain( X );
551 protein_list_ciona.add( ciona_2 );
552 protein_list_ciona.add( ciona_3 );
553 final List<GenomeWideCombinableDomains> cdc_list3 = new ArrayList<GenomeWideCombinableDomains>();
554 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
556 new BasicSpecies( "mouse" ) ) );
557 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
559 new BasicSpecies( "rabbit" ) ) );
560 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
562 new BasicSpecies( "ciona" ) ) );
563 cdc_list3.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
565 new BasicSpecies( "nemve" ) ) );
566 final DomainSimilarityCalculator calc3 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
569 final SortedSet<DomainSimilarity> sims3 = calc3
570 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
574 final Iterator<DomainSimilarity> sims_it3 = sims3.iterator();
575 final DomainSimilarity sa3 = sims_it3.next();
576 if ( !sa3.getDomainId().getId().equals( "A" ) ) {
579 final SpeciesSpecificDomainSimilariyData ssdsd = sa3.getSpeciesData().get( new BasicSpecies( "ciona" ) );
580 if ( ssdsd.getCombinableDomainIdToCountsMap().size() != 4 ) {
583 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
586 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
589 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
592 if ( ssdsd.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
595 final List<GenomeWideCombinableDomains> cdc_list4 = new ArrayList<GenomeWideCombinableDomains>();
596 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
598 new BasicSpecies( "mouse" ) ) );
599 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
601 new BasicSpecies( "rabbit" ) ) );
602 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
604 new BasicSpecies( "ciona" ) ) );
606 cdc_list4.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
608 new BasicSpecies( "nemve" ) ) );
609 final DomainSimilarityCalculator calc4 = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
612 final SortedSet<DomainSimilarity> sims4 = calc4
613 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
617 final Iterator<DomainSimilarity> sims_it4 = sims4.iterator();
618 final DomainSimilarity sa4 = sims_it4.next();
619 if ( !sa4.getDomainId().getId().equals( "A" ) ) {
622 final SpeciesSpecificDomainSimilariyData ssdsd4 = sa4.getSpeciesData().get( new BasicSpecies( "ciona" ) );
623 if ( ssdsd4.getCombinableDomainIdToCountsMap().size() != 5 ) {
626 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "A" ) ) != 3 ) {
629 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
632 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
635 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
638 if ( ssdsd4.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
641 final SortedSet<DomainSimilarity> sims4_d = calc4
642 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list4, false, true );
643 final Iterator<DomainSimilarity> sims_it4_d = sims4_d.iterator();
644 final DomainSimilarity sa4_d = sims_it4_d.next();
645 if ( !sa4_d.getDomainId().getId().equals( "A" ) ) {
648 if ( sa4_d.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
652 .isEqual( sa4_d.getMeanSimilarityScore(),
653 ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
656 if ( !TestSurfacing.isEqual( sa4_d.getMaximalSimilarityScore(), 1.0 ) ) {
659 if ( !TestSurfacing.isEqual( sa4_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
662 if ( sa4_d.getN() != 6 ) {
665 final SortedSet<DomainSimilarity> sims4_p = calc4
666 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
670 final Iterator<DomainSimilarity> sims_it4_p = sims4_p.iterator();
671 final DomainSimilarity sa4_p = sims_it4_p.next();
672 if ( !sa4_p.getDomainId().getId().equals( "A" ) ) {
675 if ( sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).size() != 5 ) {
678 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "A" ) ) ) {
681 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "B" ) ) ) {
684 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "F" ) ) ) {
687 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "G" ) ) ) {
690 if ( !sa4_p.getCombinableDomainIds( new BasicSpecies( "ciona" ) ).contains( new DomainId( "X" ) ) ) {
694 .isEqual( sa4_p.getMeanSimilarityScore(),
695 ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
698 if ( !TestSurfacing.isEqual( sa4_p.getMaximalSimilarityScore(), 1 ) ) {
701 if ( !TestSurfacing.isEqual( sa4_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
704 if ( sa4_p.getN() != 6 ) {
707 final List<GenomeWideCombinableDomains> cdc_list5 = new ArrayList<GenomeWideCombinableDomains>();
708 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
710 new BasicSpecies( "mouse" ) ) );
711 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
713 new BasicSpecies( "rabbit" ) ) );
714 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
716 new BasicSpecies( "ciona" ) ) );
717 cdc_list5.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
719 new BasicSpecies( "nemve" ) ) );
720 final SortedSet<DomainSimilarity> sims5_d = calc4
721 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list5, false, true );
722 final Iterator<DomainSimilarity> sims_it5_d = sims5_d.iterator();
723 final DomainSimilarity sa5_d = sims_it5_d.next();
724 if ( sa5_d.getSpecies().size() != 4 ) {
727 if ( !sa5_d.getSpecies().last().equals( new BasicSpecies( "rabbit" ) ) ) {
730 final SpeciesSpecificDomainSimilariyData ssdsd5 = sa5_d.getSpeciesData().get( new BasicSpecies( "ciona" ) );
731 if ( ssdsd5.getCombinableDomainIdToCountsMap().size() != 4 ) {
734 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
737 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
740 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
743 if ( ssdsd5.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
746 if ( !sa5_d.getDomainId().getId().equals( "A" ) ) {
749 final Species ciona = new BasicSpecies( "ciona" );
750 if ( sa5_d.getCombinableDomainIds( ciona ).size() != 4 ) {
753 if ( sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
756 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
759 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
762 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
765 if ( !sa5_d.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
769 .isEqual( sa5_d.getMeanSimilarityScore(),
770 ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
773 if ( !TestSurfacing.isEqual( sa5_d.getMaximalSimilarityScore(), 1.0 ) ) {
776 if ( !TestSurfacing.isEqual( sa5_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
779 if ( sa5_d.getN() != 6 ) {
782 if ( sa5_d.getMaximalDifference() != sa5_d.getMaximalDifferenceInCounts() ) {
785 if ( sa5_d.getMaximalDifference() != 11 ) {
788 if ( sa5_d.getMaximalDifferenceInCounts() != 11 ) {
791 final SortedSet<DomainSimilarity> sims5_p = calc4
792 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
796 final Iterator<DomainSimilarity> sims_it5_p = sims5_p.iterator();
797 final DomainSimilarity sa5_p = sims_it5_p.next();
798 if ( !sa5_p.getDomainId().getId().equals( "A" ) ) {
801 if ( sa5_p.getCombinableDomainIds( ciona ).size() != 4 ) {
804 if ( sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
807 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
810 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
813 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
816 if ( !sa5_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
820 .isEqual( sa5_p.getMeanSimilarityScore(),
821 ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
824 if ( !TestSurfacing.isEqual( sa5_p.getMaximalSimilarityScore(), 1 ) ) {
827 if ( !TestSurfacing.isEqual( sa5_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
830 if ( sa5_p.getN() != 6 ) {
833 if ( sa5_p.getMaximalDifference() != sa5_p.getMaximalDifferenceInCounts() ) {
836 if ( sa5_p.getMaximalDifference() != 2 ) {
839 if ( sa5_p.getMaximalDifferenceInCounts() != 2 ) {
842 final List<GenomeWideCombinableDomains> cdc_list6 = new ArrayList<GenomeWideCombinableDomains>();
843 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
845 new BasicSpecies( "mouse" ) ) );
846 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
848 new BasicSpecies( "rabbit" ) ) );
849 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
851 new BasicSpecies( "ciona" ) ) );
852 cdc_list6.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
854 new BasicSpecies( "nemve" ) ) );
855 final SortedSet<DomainSimilarity> sims6_d = calc4
856 .calculateSimilarities( new DomainCountsBasedPairwiseSimilarityCalculator(), cdc_list6, false, true );
857 final Iterator<DomainSimilarity> sims_it6_d = sims6_d.iterator();
858 final DomainSimilarity sa6_d = sims_it6_d.next();
859 if ( sa6_d.getSpecies().size() != 4 ) {
862 if ( !sa6_d.getSpecies().last().equals( new BasicSpecies( "rabbit" ) ) ) {
865 final SpeciesSpecificDomainSimilariyData ssdsd6 = sa6_d.getSpeciesData().get( new BasicSpecies( "ciona" ) );
866 if ( ssdsd6.getCombinableDomainIdToCountsMap().size() != 5 ) {
869 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "B" ) ) != 2 ) {
872 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "F" ) ) != 2 ) {
875 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "G" ) ) != 2 ) {
878 if ( ssdsd6.getNumberOfProteinsExhibitingCombinationWith( new DomainId( "X" ) ) != 3 ) {
881 if ( !sa5_d.getDomainId().getId().equals( "A" ) ) {
884 final Species ciona6 = new BasicSpecies( "ciona" );
885 if ( sa6_d.getCombinableDomainIds( ciona6 ).size() != 5 ) {
888 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "A" ) ) ) {
891 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "B" ) ) ) {
894 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "F" ) ) ) {
897 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "G" ) ) ) {
900 if ( !sa6_d.getCombinableDomainIds( ciona6 ).contains( new DomainId( "X" ) ) ) {
904 .isEqual( sa6_d.getMeanSimilarityScore(),
905 ( ( ( ( ( ( 1 + 1 ) - ( 11.0 / 13 ) ) + 1 ) - ( 11.0 / 13 ) ) + 1 + 1 + 1 ) - ( 11.0 / 13 ) ) / 6.0 ) ) {
908 if ( !TestSurfacing.isEqual( sa6_d.getMaximalSimilarityScore(), 1.0 ) ) {
911 if ( !TestSurfacing.isEqual( sa6_d.getMinimalSimilarityScore(), ( 1 - ( 11.0 / 13 ) ) ) ) {
914 if ( sa6_d.getN() != 6 ) {
917 if ( sa6_d.getMaximalDifference() != sa6_d.getMaximalDifferenceInCounts() ) {
920 if ( sa6_d.getMaximalDifference() != 11 ) {
923 if ( sa6_d.getMaximalDifferenceInCounts() != 11 ) {
926 final SortedSet<DomainSimilarity> sims6_p = calc4
927 .calculateSimilarities( new ProteinCountsBasedPairwiseDomainSimilarityCalculator(),
931 final Iterator<DomainSimilarity> sims_it6_p = sims6_p.iterator();
932 final DomainSimilarity sa6_p = sims_it6_p.next();
933 if ( !sa6_p.getDomainId().getId().equals( "A" ) ) {
936 if ( sa6_p.getCombinableDomainIds( ciona ).size() != 5 ) {
939 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "A" ) ) ) {
942 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "B" ) ) ) {
945 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "F" ) ) ) {
948 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "G" ) ) ) {
951 if ( !sa6_p.getCombinableDomainIds( ciona ).contains( new DomainId( "X" ) ) ) {
955 .isEqual( sa6_p.getMeanSimilarityScore(),
956 ( ( ( ( ( ( 1 + 1 ) - ( 2.0 / 4 ) ) + 1 ) - ( 2.0 / 4 ) ) + 1 + 1 + 1 ) - ( 2.0 / 4 ) ) / 6.0 ) ) {
959 if ( !TestSurfacing.isEqual( sa6_p.getMaximalSimilarityScore(), 1 ) ) {
962 if ( !TestSurfacing.isEqual( sa6_p.getMinimalSimilarityScore(), ( 1 - ( 2.0 / 4 ) ) ) ) {
965 if ( sa6_p.getN() != 6 ) {
968 if ( sa6_p.getMaximalDifference() != sa6_p.getMaximalDifferenceInCounts() ) {
971 if ( sa6_p.getMaximalDifference() != 2 ) {
974 if ( sa6_p.getMaximalDifferenceInCounts() != 2 ) {
978 catch ( final Exception e ) {
979 e.printStackTrace( System.out );
985 private static boolean testBasicDomainSimilarityCalculatorNotIgnoringSpeciesSpeficDomains() {
987 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
988 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
989 final Domain D = new BasicDomain( "D", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
990 final Domain E = new BasicDomain( "E", 1, 2, ( short ) 1, ( short ) 1, 0.5, -12 );
991 final Domain F = new BasicDomain( "F", 1, 2, ( short ) 1, ( short ) 1, 0.01, -12 );
992 final Domain G = new BasicDomain( "G", 1, 2, ( short ) 1, ( short ) 1, 0.001, -12 );
993 final Domain X = new BasicDomain( "X", 1, 2, ( short ) 1, ( short ) 1, 0.0001, -12 );
994 if ( !TestSurfacing.isEqual( X.getPerSequenceScore(), -12 ) ) {
997 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
998 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
999 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
1000 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
1001 mouse_1.addProteinDomain( A );
1002 mouse_1.addProteinDomain( D );
1003 mouse_1.addProteinDomain( E );
1004 rabbit_1.addProteinDomain( B );
1005 rabbit_1.addProteinDomain( E );
1006 rabbit_1.addProteinDomain( F );
1007 rabbit_1.addProteinDomain( F );
1008 rabbit_1.addProteinDomain( F );
1009 rabbit_1.addProteinDomain( F );
1010 rabbit_1.addProteinDomain( F );
1011 rabbit_1.addProteinDomain( F );
1012 ciona_1.addProteinDomain( F );
1013 ciona_1.addProteinDomain( G );
1014 ciona_1.addProteinDomain( X );
1015 nemve_1.addProteinDomain( D );
1016 nemve_1.addProteinDomain( E );
1017 nemve_1.addProteinDomain( F );
1018 nemve_1.addProteinDomain( G );
1019 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
1020 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
1021 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
1022 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
1023 protein_list_mouse.add( mouse_1 );
1024 protein_list_rabbit.add( rabbit_1 );
1025 protein_list_ciona.add( ciona_1 );
1026 protein_list_nemve.add( nemve_1 );
1027 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
1028 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
1030 new BasicSpecies( "mouse" ) ) );
1031 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
1033 new BasicSpecies( "rabbit" ) ) );
1034 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
1036 new BasicSpecies( "ciona" ) ) );
1037 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
1039 new BasicSpecies( "nemve" ) ) );
1040 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
1043 final SortedSet<DomainSimilarity> sims = calc
1044 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1048 final Iterator<DomainSimilarity> sims_it = sims.iterator();
1049 final DomainSimilarity sa = sims_it.next();
1050 if ( !sa.getDomainId().getId().equals( "A" ) ) {
1053 if ( sa.getSpeciesData().size() != 1 ) {
1056 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
1059 if ( !TestSurfacing.isEqual( sa.getMeanSimilarityScore(), 1.0 ) ) {
1062 if ( !TestSurfacing.isEqual( sa.getStandardDeviationOfSimilarityScore(), 0.0 ) ) {
1065 if ( !TestSurfacing.isEqual( sa.getMaximalSimilarityScore(), 1.0 ) ) {
1068 if ( !TestSurfacing.isEqual( sa.getMinimalSimilarityScore(), 1.0 ) ) {
1071 if ( sa.getN() != 0 ) {
1074 if ( sa.getMaximalDifference() != 0 ) {
1077 if ( sa.getMaximalDifferenceInCounts() != 0 ) {
1080 final DomainSimilarity sb = sims_it.next();
1081 if ( !sb.getDomainId().getId().equals( "B" ) ) {
1084 if ( sb.getSpeciesData().size() != 1 ) {
1087 if ( !sb.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
1090 final SortedSet<DomainSimilarity> sims2 = calc
1091 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1095 final Iterator<DomainSimilarity> sims_it2 = sims2.iterator();
1096 final DomainSimilarity sa2 = sims_it2.next();
1097 if ( !sa2.getDomainId().getId().equals( "D" ) ) {
1100 if ( sa2.getSpeciesData().size() != 2 ) {
1104 catch ( final Exception e ) {
1105 e.printStackTrace( System.out );
1111 private static boolean testBasicDomainSimilarityCalculatorRemovalOfSingles() {
1113 final Domain A = new BasicDomain( "A", 1, 2, ( short ) 1, ( short ) 1, 0.15, -12 );
1114 final Domain B = new BasicDomain( "B", 1, 2, ( short ) 1, ( short ) 1, 0.2, -12 );
1115 final Protein mouse_1 = new BasicProtein( "1", "mouse", 0 );
1116 final Protein rabbit_1 = new BasicProtein( "1", "rabbit", 0 );
1117 final Protein ciona_1 = new BasicProtein( "1", "ciona", 0 );
1118 final Protein nemve_1 = new BasicProtein( "1", "nemve", 0 );
1119 mouse_1.addProteinDomain( A );
1120 rabbit_1.addProteinDomain( A );
1121 ciona_1.addProteinDomain( A );
1122 ciona_1.addProteinDomain( A );
1123 ciona_1.addProteinDomain( A );
1124 ciona_1.addProteinDomain( A );
1125 ciona_1.addProteinDomain( A );
1126 nemve_1.addProteinDomain( A );
1127 final List<Protein> protein_list_mouse = new ArrayList<Protein>();
1128 final List<Protein> protein_list_rabbit = new ArrayList<Protein>();
1129 final List<Protein> protein_list_ciona = new ArrayList<Protein>();
1130 final List<Protein> protein_list_nemve = new ArrayList<Protein>();
1131 protein_list_mouse.add( mouse_1 );
1132 protein_list_rabbit.add( rabbit_1 );
1133 protein_list_ciona.add( ciona_1 );
1134 protein_list_nemve.add( nemve_1 );
1135 final List<GenomeWideCombinableDomains> cdc_list = new ArrayList<GenomeWideCombinableDomains>();
1136 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse,
1138 new BasicSpecies( "mouse" ) ) );
1139 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit,
1141 new BasicSpecies( "rabbit" ) ) );
1142 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona,
1144 new BasicSpecies( "ciona" ) ) );
1145 cdc_list.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve,
1147 new BasicSpecies( "nemve" ) ) );
1148 final DomainSimilarityCalculator calc = new BasicDomainSimilarityCalculator( DomainSimilarity.DomainSimilaritySortField.DOMAIN_ID,
1151 final SortedSet<DomainSimilarity> sims = calc
1152 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1156 if ( sims.size() != 1 ) {
1159 final Iterator<DomainSimilarity> sims_it = sims.iterator();
1160 final DomainSimilarity sa = sims_it.next();
1161 if ( !sa.getDomainId().getId().equals( "A" ) ) {
1164 if ( sa.getSpeciesData().size() != 4 ) {
1167 if ( !sa.getSpecies().contains( new BasicSpecies( "ciona" ) ) ) {
1170 if ( !sa.getSpecies().contains( new BasicSpecies( "mouse" ) ) ) {
1173 if ( !sa.getSpecies().contains( new BasicSpecies( "nemve" ) ) ) {
1176 if ( !sa.getSpecies().contains( new BasicSpecies( "rabbit" ) ) ) {
1179 final SortedSet<DomainSimilarity> sims_ns = calc
1180 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1184 if ( sims_ns.size() != 0 ) {
1187 final Protein mouse_2 = new BasicProtein( "1", "mouse", 0 );
1188 final Protein rabbit_2 = new BasicProtein( "1", "rabbit", 0 );
1189 final Protein ciona_2 = new BasicProtein( "1", "ciona", 0 );
1190 final Protein nemve_2 = new BasicProtein( "1", "nemve", 0 );
1191 mouse_2.addProteinDomain( A );
1192 rabbit_2.addProteinDomain( A );
1193 ciona_2.addProteinDomain( A );
1194 ciona_2.addProteinDomain( A );
1195 ciona_2.addProteinDomain( B );
1196 ciona_2.addProteinDomain( A );
1197 ciona_2.addProteinDomain( A );
1198 ciona_2.addProteinDomain( A );
1199 nemve_2.addProteinDomain( A );
1200 final List<Protein> protein_list_mouse2 = new ArrayList<Protein>();
1201 final List<Protein> protein_list_rabbit2 = new ArrayList<Protein>();
1202 final List<Protein> protein_list_ciona2 = new ArrayList<Protein>();
1203 final List<Protein> protein_list_nemve2 = new ArrayList<Protein>();
1204 protein_list_mouse2.add( mouse_2 );
1205 protein_list_rabbit2.add( rabbit_2 );
1206 protein_list_ciona2.add( ciona_2 );
1207 protein_list_nemve2.add( nemve_2 );
1208 final List<GenomeWideCombinableDomains> cdc_list2 = new ArrayList<GenomeWideCombinableDomains>();
1209 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_mouse2,
1211 new BasicSpecies( "mouse" ) ) );
1212 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_rabbit2,
1214 new BasicSpecies( "rabbit" ) ) );
1215 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_ciona2,
1217 new BasicSpecies( "ciona" ) ) );
1218 cdc_list2.add( BasicGenomeWideCombinableDomains.createInstance( protein_list_nemve2,
1220 new BasicSpecies( "nemve" ) ) );
1221 final SortedSet<DomainSimilarity> sims2 = calc
1222 .calculateSimilarities( new CombinationsBasedPairwiseDomainSimilarityCalculator(),
1226 if ( sims2.size() != 1 ) {
1230 catch ( final Exception e ) {
1231 e.printStackTrace( System.out );
1237 private static boolean testBinaryDomainCombination() {
1239 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "a", "a" );
1240 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "a" );
1241 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "a", "b" );
1242 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "B", "A" );
1243 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "A", "B" );
1244 final BasicBinaryDomainCombination s5 = new BasicBinaryDomainCombination( "c", "a" );
1245 final BasicBinaryDomainCombination s6 = new BasicBinaryDomainCombination( "b", "c" );
1246 final BasicBinaryDomainCombination s7 = new BasicBinaryDomainCombination( "d", "a" );
1247 final BasicBinaryDomainCombination s8 = new BasicBinaryDomainCombination( "b", "d" );
1248 final BinaryDomainCombination s9 = BasicBinaryDomainCombination.createInstance( "z-z=a-aa" );
1249 if ( !s9.toString().equals( "a-aa=z-z" ) ) {
1250 System.out.println( s9.toString() );
1253 if ( !s0.equals( s0 ) ) {
1256 if ( s0.equals( s1 ) ) {
1259 if ( s1.equals( s0 ) ) {
1262 if ( !s1.equals( s2 ) ) {
1265 if ( !s2.equals( s1 ) ) {
1268 if ( s2.equals( s3 ) ) {
1271 if ( s2.equals( s3 ) ) {
1274 if ( s2.equals( s4 ) ) {
1277 final SortedSet<BasicBinaryDomainCombination> sorted = new TreeSet<BasicBinaryDomainCombination>();
1290 if ( sorted.size() != 6 ) {
1293 final DirectedBinaryDomainCombination aa = new DirectedBinaryDomainCombination( "a", "a" );
1294 final DirectedBinaryDomainCombination ba = new DirectedBinaryDomainCombination( "b", "a" );
1295 final DirectedBinaryDomainCombination ab = new DirectedBinaryDomainCombination( "a", "b" );
1296 final DirectedBinaryDomainCombination bb = new DirectedBinaryDomainCombination( "b", "b" );
1297 if ( !aa.equals( aa ) ) {
1300 if ( aa.equals( bb ) ) {
1303 if ( ab.equals( ba ) ) {
1306 if ( ba.equals( ab ) ) {
1309 if ( !ab.equals( ab ) ) {
1312 if ( ab.equals( aa ) ) {
1315 if ( ab.equals( bb ) ) {
1319 catch ( final Exception e ) {
1320 e.printStackTrace( System.out );
1326 private static boolean testBinaryStateMatrixToGainLossMatrix( final File test_dir ) {
1327 final BinaryStates I = BinaryStates.PRESENT;
1328 final BinaryStates O = BinaryStates.ABSENT;
1330 final CharacterStateMatrix<BinaryStates> binary_states_matrix_0 = new BasicCharacterStateMatrix<BinaryStates>( 7,
1332 binary_states_matrix_0.setIdentifier( 0, "A" );
1333 binary_states_matrix_0.setIdentifier( 1, "B" );
1334 binary_states_matrix_0.setIdentifier( 2, "C" );
1335 binary_states_matrix_0.setIdentifier( 3, "D" );
1336 binary_states_matrix_0.setIdentifier( 4, "1" );
1337 binary_states_matrix_0.setIdentifier( 5, "2" );
1338 binary_states_matrix_0.setIdentifier( 6, "3" );
1339 binary_states_matrix_0.setState( 0, 0, O );
1340 binary_states_matrix_0.setState( 1, 0, O );
1341 binary_states_matrix_0.setState( 2, 0, O );
1342 binary_states_matrix_0.setState( 3, 0, O );
1343 binary_states_matrix_0.setState( 4, 0, O );
1344 binary_states_matrix_0.setState( 5, 0, O );
1345 binary_states_matrix_0.setState( 6, 0, O );
1346 binary_states_matrix_0.setState( 0, 1, I );
1347 binary_states_matrix_0.setState( 1, 1, O );
1348 binary_states_matrix_0.setState( 2, 1, O );
1349 binary_states_matrix_0.setState( 3, 1, O );
1350 binary_states_matrix_0.setState( 4, 1, O );
1351 binary_states_matrix_0.setState( 5, 1, O );
1352 binary_states_matrix_0.setState( 6, 1, O );
1353 binary_states_matrix_0.setState( 0, 2, O );
1354 binary_states_matrix_0.setState( 1, 2, O );
1355 binary_states_matrix_0.setState( 2, 2, O );
1356 binary_states_matrix_0.setState( 3, 2, O );
1357 binary_states_matrix_0.setState( 4, 2, I );
1358 binary_states_matrix_0.setState( 5, 2, O );
1359 binary_states_matrix_0.setState( 6, 2, O );
1360 binary_states_matrix_0.setState( 0, 3, I );
1361 binary_states_matrix_0.setState( 1, 3, O );
1362 binary_states_matrix_0.setState( 2, 3, O );
1363 binary_states_matrix_0.setState( 3, 3, O );
1364 binary_states_matrix_0.setState( 4, 3, I );
1365 binary_states_matrix_0.setState( 5, 3, O );
1366 binary_states_matrix_0.setState( 6, 3, I );
1367 binary_states_matrix_0.setState( 0, 4, I );
1368 binary_states_matrix_0.setState( 1, 4, O );
1369 binary_states_matrix_0.setState( 2, 4, I );
1370 binary_states_matrix_0.setState( 3, 4, O );
1371 binary_states_matrix_0.setState( 4, 4, I );
1372 binary_states_matrix_0.setState( 5, 4, O );
1373 binary_states_matrix_0.setState( 6, 4, I );
1374 binary_states_matrix_0.setState( 0, 5, I );
1375 binary_states_matrix_0.setState( 1, 5, I );
1376 binary_states_matrix_0.setState( 2, 5, I );
1377 binary_states_matrix_0.setState( 3, 5, I );
1378 binary_states_matrix_0.setState( 4, 5, I );
1379 binary_states_matrix_0.setState( 5, 5, I );
1380 binary_states_matrix_0.setState( 6, 5, I );
1381 final String[] character_labels_0 = new String[ 6 ];
1382 character_labels_0[ 0 ] = "first";
1383 character_labels_0[ 1 ] = "second";
1384 character_labels_0[ 2 ] = "third";
1385 character_labels_0[ 3 ] = "forth";
1386 character_labels_0[ 4 ] = "fifth";
1387 character_labels_0[ 5 ] = "sixth";
1388 final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
1389 final Phylogeny phylogeny_0 = factory.create( "(((A,B)1,C)2,D)3", new NHXParser() )[ 0 ];
1390 final DomainParsimonyCalculator dom_pars = DomainParsimonyCalculator.createInstance( phylogeny_0 );
1391 dom_pars.executeOnGivenBinaryStatesMatrix( binary_states_matrix_0, character_labels_0 );
1392 final CharacterStateMatrix<GainLossStates> gl_matrix_0 = dom_pars.getGainLossMatrix();
1393 // final StringWriter sw = new StringWriter();
1394 // gl_matrix_0.toWriter( sw );
1395 // System.out.println( sw.toString() );
1396 if ( dom_pars.getCost() != 13 ) {
1399 if ( dom_pars.getTotalGains() != 5 ) {
1402 if ( dom_pars.getTotalLosses() != 8 ) {
1405 if ( dom_pars.getTotalUnchanged() != 29 ) {
1408 if ( gl_matrix_0.getState( "A", 1 ) != GainLossStates.GAIN ) {
1411 if ( gl_matrix_0.getState( "A", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1414 if ( gl_matrix_0.getState( "B", 4 ) != GainLossStates.LOSS ) {
1417 if ( gl_matrix_0.getState( "C", 4 ) != GainLossStates.GAIN ) {
1420 if ( gl_matrix_0.getState( "D", 4 ) != GainLossStates.LOSS ) {
1423 if ( gl_matrix_0.getState( "1", 4 ) != GainLossStates.GAIN ) {
1426 if ( gl_matrix_0.getState( "2", 4 ) != GainLossStates.LOSS ) {
1429 if ( gl_matrix_0.getState( "3", 4 ) != GainLossStates.UNCHANGED_PRESENT ) {
1433 catch ( final Exception e ) {
1434 e.printStackTrace( System.out );
1440 private static boolean testCombinableDomains() {
1442 final Domain key0 = new BasicDomain( "key0", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1443 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1444 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1445 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1446 final CombinableDomains cd0 = new BasicCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
1447 cd0.addCombinableDomain( a.getDomainId() );
1448 cd0.addCombinableDomain( b.getDomainId() );
1449 cd0.addCombinableDomain( b.getDomainId() );
1450 cd0.addCombinableDomain( c.getDomainId() );
1451 cd0.addCombinableDomain( c.getDomainId() );
1452 cd0.addCombinableDomain( c.getDomainId() );
1453 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
1456 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
1459 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
1462 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
1465 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
1468 if ( cd0.getAllDomains().size() != 4 ) {
1471 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
1474 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
1477 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
1480 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
1483 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
1486 final BasicBinaryDomainCombination s0 = new BasicBinaryDomainCombination( "key0", "a" );
1487 final BasicBinaryDomainCombination s1 = new BasicBinaryDomainCombination( "b", "key0" );
1488 final BasicBinaryDomainCombination s2 = new BasicBinaryDomainCombination( "key0", "c" );
1489 final BasicBinaryDomainCombination s3 = new BasicBinaryDomainCombination( "key0", "cc" );
1490 final BasicBinaryDomainCombination s4 = new BasicBinaryDomainCombination( "c", "key0" );
1491 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
1494 if ( !cd0.toBinaryDomainCombinations().contains( s1 ) ) {
1497 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
1500 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
1503 if ( !cd0.toBinaryDomainCombinations().contains( s4 ) ) {
1506 final Domain key1 = new BasicDomain( "key1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1507 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1508 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1509 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1510 final CombinableDomains cd1 = new BasicCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
1511 cd1.addCombinableDomain( a1.getDomainId() );
1512 cd1.addCombinableDomain( b1.getDomainId() );
1513 cd1.addCombinableDomain( c1.getDomainId() );
1514 cd1.addCombinableDomain( key1.getDomainId() );
1515 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
1518 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
1521 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
1524 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
1527 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
1530 if ( cd1.getAllDomains().size() != 4 ) {
1533 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
1536 final BasicBinaryDomainCombination kk = new BasicBinaryDomainCombination( "key1", "key1" );
1537 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
1541 catch ( final Exception e ) {
1542 e.printStackTrace( System.out );
1548 private static boolean testCombinationsBasedPairwiseSimilarityCalculator() {
1550 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1551 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1552 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1553 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1554 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1555 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1556 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1557 new BasicSpecies( "rabbit" ) );
1558 one.addCombinableDomain( a.getDomainId() );
1559 one.addCombinableDomain( a.getDomainId() );
1560 two.addCombinableDomain( new BasicDomain( "A", 1, 5, ( short ) 1, ( short ) 4, 0.1, -12 ).getDomainId() );
1561 two.addCombinableDomain( b.getDomainId() );
1562 two.addCombinableDomain( c.getDomainId() );
1563 final PairwiseDomainSimilarityCalculator calc = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1564 final PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1565 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 / ( 1 + 2 ) ) ) {
1568 if ( s1.getDifferenceInCounts() != ( 1 - 3 ) ) {
1571 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s1 ).getNumberOfDifferentDomains() != 2 ) {
1574 one.addCombinableDomain( b.getDomainId() );
1575 one.addCombinableDomain( c.getDomainId() );
1576 final PairwiseDomainSimilarity s2 = calc.calculateSimilarity( one, two );
1577 if ( !TestSurfacing.isEqual( s2.getSimilarityScore(), 3.0 / ( 0 + 3 ) ) ) {
1580 if ( s2.getDifferenceInCounts() != 0 ) {
1583 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s2 ).getNumberOfDifferentDomains() != 0 ) {
1586 final Domain d = new BasicDomain( "D", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1587 final Domain e = new BasicDomain( "E", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1588 final Domain f = new BasicDomain( "F", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1589 one.addCombinableDomain( d.getDomainId() );
1590 one.addCombinableDomain( d.getDomainId() );
1591 one.addCombinableDomain( e.getDomainId() );
1592 one.addCombinableDomain( f.getDomainId() );
1593 final PairwiseDomainSimilarity s3 = calc.calculateSimilarity( one, two );
1594 if ( !TestSurfacing.isEqual( s3.getSimilarityScore(), 3.0 / ( 3 + 3 ) ) ) {
1597 if ( s3.getDifferenceInCounts() != ( 6 - 3 ) ) {
1600 if ( ( ( CombinationsBasedPairwiseDomainSimilarity ) s3 ).getNumberOfDifferentDomains() != 3 ) {
1603 final Domain aaa = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1604 final Domain bbb = new BasicDomain( "bbb", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1605 final Domain three_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1606 final Domain four_key = new BasicDomain( "bcl2", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1607 final CombinableDomains three = new BasicCombinableDomains( three_key.getDomainId(),
1608 new BasicSpecies( "mouse" ) );
1609 final CombinableDomains four = new BasicCombinableDomains( four_key.getDomainId(),
1610 new BasicSpecies( "rabbit" ) );
1611 three.addCombinableDomain( aaa.getDomainId() );
1612 four.addCombinableDomain( bbb.getDomainId() );
1613 final PairwiseDomainSimilarityCalculator calc2 = new CombinationsBasedPairwiseDomainSimilarityCalculator();
1614 final PairwiseDomainSimilarity s4 = calc2.calculateSimilarity( three, four );
1615 if ( !TestSurfacing.isEqual( s4.getSimilarityScore(), 0.0 / ( 0 + 2 ) ) ) {
1618 final Domain aaa2 = new BasicDomain( "aaa", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1619 four.addCombinableDomain( aaa2.getDomainId() );
1620 final PairwiseDomainSimilarity s5 = calc.calculateSimilarity( three, four );
1621 if ( !TestSurfacing.isEqual( s5.getSimilarityScore(), 1.0 / ( 1 + 1 ) ) ) {
1625 catch ( final Exception e ) {
1626 e.printStackTrace( System.out );
1632 private static boolean testCopyNumberBasedPairwiseSimilarityCalculator() {
1634 final Domain one_key = new BasicDomain( "bcl2", 4, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1635 final Domain two_key = new BasicDomain( "bcl2", 5, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1636 final CombinableDomains one = new BasicCombinableDomains( one_key.getDomainId(), new BasicSpecies( "mouse" ) );
1637 final CombinableDomains two = new BasicCombinableDomains( two_key.getDomainId(),
1638 new BasicSpecies( "rabbit" ) );
1639 one.setKeyDomainCount( 2 );
1640 two.setKeyDomainCount( 3 );
1641 final PairwiseDomainSimilarityCalculator calc = new DomainCountsBasedPairwiseSimilarityCalculator();
1642 PairwiseDomainSimilarity s1 = calc.calculateSimilarity( one, two );
1643 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( ( 3 - 2.0 ) / ( 2 + 3 ) ) ) ) {
1646 if ( s1.getDifferenceInCounts() != ( 2 - 3 ) ) {
1649 one.setKeyDomainCount( 1 );
1650 two.setKeyDomainCount( 1 );
1651 s1 = calc.calculateSimilarity( one, two );
1652 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 ) ) {
1655 if ( s1.getDifferenceInCounts() != ( 1 - 1 ) ) {
1658 one.setKeyDomainCount( 1 );
1659 two.setKeyDomainCount( 1000 );
1660 s1 = calc.calculateSimilarity( one, two );
1661 if ( !TestSurfacing.isEqual( s1.getSimilarityScore(), 1.0 - ( 999.0 / 1001 ) ) ) {
1664 if ( s1.getDifferenceInCounts() != ( 1 - 1000 ) ) {
1668 catch ( final Exception e ) {
1669 e.printStackTrace( System.out );
1675 private static boolean testDirectedCombinableDomains() {
1677 final Domain key0 = new BasicDomain( "key0", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 );
1678 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1679 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1680 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1681 final CombinableDomains cd0 = new DirectedCombinableDomains( key0.getDomainId(), new BasicSpecies( "eel" ) );
1682 cd0.addCombinableDomain( a.getDomainId() );
1683 cd0.addCombinableDomain( b.getDomainId() );
1684 cd0.addCombinableDomain( b.getDomainId() );
1685 cd0.addCombinableDomain( c.getDomainId() );
1686 cd0.addCombinableDomain( c.getDomainId() );
1687 cd0.addCombinableDomain( c.getDomainId() );
1688 if ( cd0.getNumberOfCombinableDomains() != 3 ) {
1691 if ( cd0.getNumberOfProteinsExhibitingCombination( a.getDomainId() ) != 1 ) {
1694 if ( cd0.getNumberOfProteinsExhibitingCombination( b.getDomainId() ) != 2 ) {
1697 if ( cd0.getNumberOfProteinsExhibitingCombination( c.getDomainId() ) != 3 ) {
1700 if ( cd0.getNumberOfProteinsExhibitingCombination( key0.getDomainId() ) != 0 ) {
1703 if ( cd0.getAllDomains().size() != 4 ) {
1706 if ( !cd0.getAllDomains().contains( a.getDomainId() ) ) {
1709 if ( !cd0.getAllDomains().contains( b.getDomainId() ) ) {
1712 if ( !cd0.getAllDomains().contains( c.getDomainId() ) ) {
1715 if ( !cd0.getAllDomains().contains( key0.getDomainId() ) ) {
1718 if ( cd0.toBinaryDomainCombinations().size() != 3 ) {
1721 final BinaryDomainCombination s0 = new DirectedBinaryDomainCombination( "key0", "a" );
1722 final BinaryDomainCombination s1 = new DirectedBinaryDomainCombination( "b", "key0" );
1723 final BinaryDomainCombination s2 = new DirectedBinaryDomainCombination( "key0", "c" );
1724 final BinaryDomainCombination s3 = new DirectedBinaryDomainCombination( "key0", "cc" );
1725 final BinaryDomainCombination s4 = new DirectedBinaryDomainCombination( "a", "b" );
1726 final BinaryDomainCombination s5 = new DirectedBinaryDomainCombination( "b", "a" );
1727 final BinaryDomainCombination s6 = new DirectedBinaryDomainCombination( "key0", "b" );
1728 final BinaryDomainCombination s7 = new DirectedBinaryDomainCombination( "a", "key0" );
1729 final BinaryDomainCombination s8 = new DirectedBinaryDomainCombination( "c", "key0" );
1730 if ( !cd0.toBinaryDomainCombinations().contains( s0 ) ) {
1733 if ( cd0.toBinaryDomainCombinations().contains( s1 ) ) {
1736 if ( !cd0.toBinaryDomainCombinations().contains( s2 ) ) {
1739 if ( cd0.toBinaryDomainCombinations().contains( s3 ) ) {
1742 if ( cd0.toBinaryDomainCombinations().contains( s4 ) ) {
1745 if ( cd0.toBinaryDomainCombinations().contains( s5 ) ) {
1748 if ( !cd0.toBinaryDomainCombinations().contains( s6 ) ) {
1751 if ( cd0.toBinaryDomainCombinations().contains( s7 ) ) {
1754 if ( cd0.toBinaryDomainCombinations().contains( s8 ) ) {
1757 final Domain key1 = new BasicDomain( "key1", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 );
1758 final Domain a1 = new BasicDomain( "a1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1759 final Domain b1 = new BasicDomain( "b1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1760 final Domain c1 = new BasicDomain( "c1", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
1761 final CombinableDomains cd1 = new DirectedCombinableDomains( key1.getDomainId(), new BasicSpecies( "eel" ) );
1762 cd1.addCombinableDomain( a1.getDomainId() );
1763 cd1.addCombinableDomain( b1.getDomainId() );
1764 cd1.addCombinableDomain( c1.getDomainId() );
1765 cd1.addCombinableDomain( key1.getDomainId() );
1766 if ( cd1.getNumberOfCombinableDomains() != 4 ) {
1769 if ( cd1.getNumberOfProteinsExhibitingCombination( a1.getDomainId() ) != 1 ) {
1772 if ( cd1.getNumberOfProteinsExhibitingCombination( b1.getDomainId() ) != 1 ) {
1775 if ( cd1.getNumberOfProteinsExhibitingCombination( c1.getDomainId() ) != 1 ) {
1778 if ( cd1.getNumberOfProteinsExhibitingCombination( key1.getDomainId() ) != 1 ) {
1781 if ( cd1.getAllDomains().size() != 4 ) {
1784 if ( cd1.toBinaryDomainCombinations().size() != 4 ) {
1787 final BinaryDomainCombination kk = new DirectedBinaryDomainCombination( "key1", "key1" );
1788 if ( !cd1.toBinaryDomainCombinations().contains( kk ) ) {
1792 catch ( final Exception e ) {
1793 e.printStackTrace( System.out );
1799 private static boolean testDirectedness() {
1801 final BinaryStates X = BinaryStates.PRESENT;
1802 final BinaryStates O = BinaryStates.ABSENT;
1803 final GainLossStates G = GainLossStates.GAIN;
1804 final GainLossStates L = GainLossStates.LOSS;
1805 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
1806 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
1807 final Protein one_1 = new BasicProtein( "one", "1", 0 );
1808 final Protein two_1 = new BasicProtein( "two", "1", 0 );
1809 final Protein three_1 = new BasicProtein( "three", "1", 0 );
1810 final Protein four_1 = new BasicProtein( "four", "1", 0 );
1811 final Protein five_1 = new BasicProtein( "five", "1", 0 );
1812 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1813 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1814 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1815 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1816 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1817 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1818 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1819 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1820 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1821 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1822 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1823 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1824 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1825 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1826 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1827 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
1828 final List<Protein> list_1 = new ArrayList<Protein>();
1829 list_1.add( one_1 );
1830 list_1.add( two_1 );
1831 list_1.add( three_1 );
1832 list_1.add( four_1 );
1833 list_1.add( five_1 );
1834 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
1835 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED );
1836 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "B" ) ) ) {
1839 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "A" ) ) ) {
1842 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "A" ) ) ) {
1845 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "C" ) ) ) {
1848 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "A" ) ) ) {
1851 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "C" ) ) ) {
1854 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "X" ) ) ) {
1857 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "Y" ) ) ) {
1860 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
1863 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
1866 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "A" ) ) ) {
1869 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "A" ) ) ) {
1872 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "C", "B" ) ) ) {
1875 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "X", "Y" ) ) ) {
1878 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "X" ) ) ) {
1881 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "Y" ) ) ) {
1884 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "A", "X" ) ) ) {
1887 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "Y", "C" ) ) ) {
1890 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "N" ) ) ) {
1893 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "M" ) ) ) {
1896 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "N", "P" ) ) ) {
1899 if ( !gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "M", "P" ) ) ) {
1902 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "N" ) ) ) {
1905 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "P", "M" ) ) ) {
1908 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
1911 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
1914 if ( gwcd_1.toBinaryDomainCombinations().contains( new DirectedBinaryDomainCombination( "B", "B" ) ) ) {
1917 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
1918 // gwcd_list.add( gwcd_1 );
1919 // gwcd_list.add( gwcd_2 );
1920 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
1921 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
1922 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
1923 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
1924 // if ( matrix_d.getState( 0, 0 ) != X ) {
1927 // if ( matrix_bc.getState( 0, 0 ) != X ) {
1932 // final BasicCharacterStateMatrix<BinaryStates> dm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
1933 // { X, X, X, X, X, X }, { X, X, X, X, X, X } } );
1934 // if ( !matrix_d.equals( dm ) ) {
1937 // final BasicCharacterStateMatrix<BinaryStates> bcm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] {
1938 // { X, O, X, X, X, X, O, X, X, O, X, X }, { X, X, X, O, O, O, O, X, O, O, X, X } } );
1939 // if ( !matrix_d.equals( dm ) ) {
1942 //``````````````````````````
1943 // final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
1944 // gwcd_list.add( one );
1945 // gwcd_list.add( two );
1946 // gwcd_list.add( three );
1947 // gwcd_list.add( four );
1948 // final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimony
1949 // .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
1950 // final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimony
1951 // .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
1952 // // System.out.println( "d:" );
1953 // // System.out.println(matrix_d.toStringBuffer().toString() );
1954 // // System.out.println( "bc:" );
1955 // // System.out.println(matrix_bc.toStringBuffer().toString() );
1956 // // 1 a b c e f g h l m
1957 // // 2 a b c e f g i n o
1958 // // 3 a b d e f g j p q
1960 // if ( matrix_d.getState( 0, 0 ) != X ) {
1963 // if ( matrix_d.getState( 0, 1 ) != X ) {
1966 // if ( matrix_d.getState( 0, 2 ) != X ) {
1969 // if ( matrix_d.getState( 0, 3 ) != O ) {
1972 // if ( matrix_d.getState( 0, 4 ) != X ) {
1975 // if ( matrix_d.getState( 0, 5 ) != X ) {
1978 // if ( matrix_d.getState( 0, 6 ) != X ) {
1981 // if ( matrix_d.getState( 0, 7 ) != X ) {
1984 // if ( matrix_d.getState( 0, 8 ) != O ) {
1987 // // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
1988 // // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
1989 // // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
1991 // if ( matrix_bc.getState( 0, 0 ) != X ) {
1994 // if ( matrix_bc.getState( 0, 1 ) != X ) {
1997 // if ( matrix_bc.getState( 0, 2 ) != X ) {
2000 // if ( matrix_bc.getState( 0, 3 ) != O ) {
2003 // if ( matrix_bc.getState( 0, 4 ) != X ) {
2006 // if ( matrix_bc.getState( 1, 0 ) != O ) {
2009 // if ( matrix_bc.getState( 1, 1 ) != X ) {
2012 // if ( matrix_bc.getState( 1, 2 ) != X ) {
2015 // if ( matrix_bc.getState( 1, 3 ) != O ) {
2018 // if ( matrix_bc.getState( 1, 4 ) != X ) {
2021 // if ( matrix_bc.getState( 2, 0 ) != O ) {
2024 // if ( matrix_bc.getState( 2, 1 ) != X ) {
2027 // if ( matrix_bc.getState( 2, 2 ) != O ) {
2030 // if ( matrix_bc.getState( 2, 3 ) != X ) {
2033 // if ( matrix_bc.getState( 2, 4 ) != X ) {
2036 // final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
2037 // final String p0_str = "((one,two)1-2,(three,four)3-4)root";
2038 // final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
2039 // final DomainParsimony dp0 = DomainParsimony.createInstance( p0, gwcd_list );
2040 // dp0.executeDolloParsimonyOnDomainPresence();
2041 // final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
2042 // final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
2043 // dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2044 // final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
2045 // final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
2046 // if ( is_matrix_d.getState( "root", "A" ) != X ) {
2049 // if ( is_matrix_d.getState( "root", "B" ) != X ) {
2052 // if ( is_matrix_d.getState( "root", "C" ) != O ) {
2055 // if ( is_matrix_d.getState( "root", "D" ) != O ) {
2058 // if ( is_matrix_d.getState( "root", "E" ) != X ) {
2061 // if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
2064 // if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
2067 // if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
2070 // if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
2073 // if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
2076 // if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
2079 // if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
2082 // if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
2085 // if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
2088 // if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
2091 // if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
2094 // if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
2097 // if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
2100 // if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
2103 // final Protein ab_1 = new BasicProtein( "ab", "one" );
2104 // ab_1.addProteinDomain( a );
2105 // ab_1.addProteinDomain( b );
2106 // final Protein ac_1 = new BasicProtein( "ac", "one" );
2107 // ac_1.addProteinDomain( a );
2108 // ac_1.addProteinDomain( c );
2109 // final Protein de_1 = new BasicProtein( "de", "one" );
2110 // de_1.addProteinDomain( d );
2111 // de_1.addProteinDomain( e );
2112 // final Protein ac_2 = new BasicProtein( "ac", "two" );
2113 // ac_2.addProteinDomain( a );
2114 // ac_2.addProteinDomain( c );
2115 // final Protein ab_3 = new BasicProtein( "ab", "three" );
2116 // ab_3.addProteinDomain( a );
2117 // ab_3.addProteinDomain( b );
2118 // final Protein de_4 = new BasicProtein( "de", "four" );
2119 // de_4.addProteinDomain( d );
2120 // de_4.addProteinDomain( e );
2121 // final Protein ab_6 = new BasicProtein( "ab", "six" );
2122 // ab_6.addProteinDomain( a );
2123 // ab_6.addProteinDomain( b );
2124 // final List<Protein> spec_one = new ArrayList<Protein>();
2125 // final List<Protein> spec_two = new ArrayList<Protein>();
2126 // final List<Protein> spec_three = new ArrayList<Protein>();
2127 // final List<Protein> spec_four = new ArrayList<Protein>();
2128 // final List<Protein> spec_five = new ArrayList<Protein>();
2129 // final List<Protein> spec_six = new ArrayList<Protein>();
2130 // final List<Protein> spec_seven = new ArrayList<Protein>();
2131 // spec_one.add( ab_1 );
2132 // spec_one.add( ac_1 );
2133 // spec_one.add( de_1 );
2134 // spec_two.add( ac_2 );
2135 // spec_three.add( ab_3 );
2136 // spec_four.add( de_4 );
2137 // spec_six.add( ab_6 );
2138 // final GenomeWideCombinableDomains one_gwcd = BasicGenomeWideCombinableDomains
2139 // .createInstance( spec_one, false, new BasicSpecies( "one" ), false );
2140 // final GenomeWideCombinableDomains two_gwcd = BasicGenomeWideCombinableDomains
2141 // .createInstance( spec_two, false, new BasicSpecies( "two" ), false );
2142 // final GenomeWideCombinableDomains three_gwcd = BasicGenomeWideCombinableDomains
2143 // .createInstance( spec_three, false, new BasicSpecies( "three" ), false );
2144 // final GenomeWideCombinableDomains four_gwcd = BasicGenomeWideCombinableDomains
2145 // .createInstance( spec_four, false, new BasicSpecies( "four" ), false );
2146 // final GenomeWideCombinableDomains five_gwcd = BasicGenomeWideCombinableDomains
2147 // .createInstance( spec_five, false, new BasicSpecies( "five" ), false );
2148 // final GenomeWideCombinableDomains six_gwcd = BasicGenomeWideCombinableDomains
2149 // .createInstance( spec_six, false, new BasicSpecies( "six" ), false );
2150 // final GenomeWideCombinableDomains seven_gwcd = BasicGenomeWideCombinableDomains
2151 // .createInstance( spec_seven, false, new BasicSpecies( "seven" ), false
2153 // final List<GenomeWideCombinableDomains> gwcd_list1 = new ArrayList<GenomeWideCombinableDomains>();
2154 // gwcd_list1.add( one_gwcd );
2155 // gwcd_list1.add( two_gwcd );
2156 // gwcd_list1.add( three_gwcd );
2157 // gwcd_list1.add( four_gwcd );
2158 // gwcd_list1.add( five_gwcd );
2159 // gwcd_list1.add( six_gwcd );
2160 // gwcd_list1.add( seven_gwcd );
2161 // final PhylogenyFactory factory1 = ParserBasedPhylogenyFactory.getInstance();
2162 // final String p1_str = "(((((one,two)12,three)123,(four,five)45)12345,six)123456,seven)root";
2163 // final Phylogeny p1 = factory1.create( p1_str, new NHXParser() )[ 0 ];
2164 // final DomainParsimony dp1 = DomainParsimony.createInstance( p1, gwcd_list1 );
2165 // dp1.executeDolloParsimonyOnDomainPresence();
2166 // final CharacterStateMatrix<GainLossStates> gl_dollo_d = dp1.getGainLossMatrix();
2167 // final CharacterStateMatrix<BinaryStates> i_dollo_d = dp1.getInternalStatesMatrix();
2168 // if ( dp1.getCost() != 14 ) {
2171 // if ( dp1.getTotalGains() != 5 ) {
2174 // if ( dp1.getTotalLosses() != 9 ) {
2177 // if ( dp1.getTotalUnchanged() != 51 ) {
2180 // if ( dp1.getNetGainsOnNode( "45" ) != -2 ) {
2183 // if ( dp1.getSumOfGainsOnNode( "45" ) != 0 ) {
2186 // if ( dp1.getSumOfLossesOnNode( "45" ) != 2 ) {
2189 // if ( dp1.getSumOfUnchangedOnNode( "45" ) != 3 ) {
2192 // if ( dp1.getSumOfUnchangedPresentOnNode( "45" ) != 2 ) {
2195 // if ( dp1.getSumOfUnchangedAbsentOnNode( "45" ) != 1 ) {
2198 // if ( dp1.getUnitsGainedOnNode( "45" ).contains( "A" ) ) {
2201 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A" ) ) {
2204 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "B" ) ) {
2207 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D" ) ) {
2210 // if ( !dp1.getUnitsOnNode( "12" ).contains( "A" ) ) {
2213 // if ( !dp1.getUnitsOnNode( "12" ).contains( "B" ) ) {
2216 // if ( !dp1.getUnitsOnNode( "12" ).contains( "C" ) ) {
2219 // if ( !dp1.getUnitsOnNode( "12" ).contains( "D" ) ) {
2222 // if ( !dp1.getUnitsOnNode( "12" ).contains( "E" ) ) {
2225 // if ( dp1.getNetGainsOnNode( "123456" ) != 2 ) {
2228 // if ( dp1.getSumOfGainsOnNode( "123456" ) != 2 ) {
2231 // dp1.executeDolloParsimonyOnBinaryDomainCombintionPresence();
2232 // final CharacterStateMatrix<GainLossStates> gl_dollo_bc = dp1.getGainLossMatrix();
2233 // final CharacterStateMatrix<BinaryStates> i_dollo_bc = dp1.getInternalStatesMatrix();
2234 // if ( dp1.getCost() != 8 ) {
2237 // if ( dp1.getTotalGains() != 3 ) {
2240 // if ( dp1.getTotalLosses() != 5 ) {
2243 // if ( dp1.getTotalUnchanged() != 31 ) {
2246 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2249 // if ( !dp1.getUnitsGainedOnNode( "12345" ).contains( "D=E" ) ) {
2252 // dp1.executeFitchParsimonyOnDomainPresence();
2253 // final CharacterStateMatrix<GainLossStates> gl_fitch_d = dp1.getGainLossMatrix();
2254 // final CharacterStateMatrix<BinaryStates> i_fitch_d = dp1.getInternalStatesMatrix();
2255 // if ( dp1.getCost() != 10 ) {
2258 // if ( dp1.getTotalGains() != 7 ) {
2261 // if ( dp1.getTotalLosses() != 3 ) {
2264 // if ( dp1.getTotalUnchanged() != 55 ) {
2267 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "E" ) ) {
2270 // dp1.executeFitchParsimonyOnBinaryDomainCombintion();
2271 // final CharacterStateMatrix<GainLossStates> gl_fitch_bc = dp1.getGainLossMatrix();
2272 // final CharacterStateMatrix<BinaryStates> i_fitch_bc = dp1.getInternalStatesMatrix();
2273 // if ( dp1.getCost() != 6 ) {
2276 // if ( dp1.getTotalGains() != 4 ) {
2279 // if ( dp1.getTotalLosses() != 2 ) {
2282 // if ( dp1.getTotalUnchanged() != 33 ) {
2285 // if ( !dp1.getUnitsLostOnNode( "45" ).contains( "A=B" ) ) {
2288 // if ( !dp1.getUnitsGainedOnNode( "four" ).contains( "D=E" ) ) {
2291 // if ( dp1.getNetGainsOnNode( "two" ) != -1 ) {
2294 // if ( dp1.getNetGainsOnNode( "123" ) != 0 ) {
2297 // if ( dp1.getSumOfUnchangedPresentOnNode( "123" ) != 1 ) {
2300 // if ( dp1.getSumOfUnchangedAbsentOnNode( "123" ) != 2 ) {
2303 // if ( dp1.getSumOfUnchangedOnNode( "123" ) != 3 ) {
2306 // if ( dp1.getSumOfUnchangedOnNode( "two" ) != 2 ) {
2309 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "two" ).contains( "D=E" ) ) {
2312 // if ( !dp1.getUnitsUnchangedPresentOnNode( "two" ).contains( "A=C" ) ) {
2315 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "A=C" ) ) {
2318 // if ( !dp1.getUnitsUnchangedPresentOnNode( "123" ).contains( "A=B" ) ) {
2321 // if ( !dp1.getUnitsUnchangedAbsentOnNode( "123" ).contains( "D=E" ) ) {
2324 // CharacterStateMatrix<BinaryStates> bsm = null;
2325 // CharacterStateMatrix<GainLossStates> glm = null;
2326 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, X, X },
2327 // { 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 } } );
2328 // if ( !bsm.equals( i_dollo_d ) ) {
2331 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X, O, O },
2332 // { 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 } } );
2333 // if ( !bsm.equals( i_fitch_d ) ) {
2336 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, P, P },
2337 // { 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 },
2338 // { 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 },
2339 // { A, A, A, A, A }, { A, A, A, A, A } } );
2340 // if ( !glm.equals( gl_dollo_d ) ) {
2343 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P, G, G },
2344 // { 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 },
2345 // { 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 },
2346 // { A, A, A, A, A }, { A, A, A, A, A } } );
2347 // if ( !glm.equals( gl_fitch_d ) ) {
2350 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, X }, { X, O, X },
2351 // { O, O, X }, { X, O, X }, { X, O, O }, { O, O, O } } );
2352 // if ( !bsm.equals( i_dollo_bc ) ) {
2355 // bsm = new BasicCharacterStateMatrix<BinaryStates>( new BinaryStates[][] { { X, X, O }, { X, O, O },
2356 // { O, O, O }, { X, O, O }, { X, O, O }, { O, O, O } } );
2357 // if ( !bsm.equals( i_fitch_bc ) ) {
2360 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, P }, { L, P, L },
2361 // { P, G, P }, { P, A, L }, { P, A, P }, { A, A, P }, { A, A, L }, { L, A, P }, { P, A, G },
2362 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2363 // if ( !glm.equals( gl_dollo_bc ) ) {
2366 // glm = new BasicCharacterStateMatrix<GainLossStates>( new GainLossStates[][] { { P, P, G }, { L, P, A },
2367 // { P, G, A }, { P, A, A }, { P, A, A }, { A, A, G }, { A, A, A }, { L, A, A }, { P, A, A },
2368 // { P, A, A }, { G, A, A }, { A, A, A }, { A, A, A } } );
2369 // if ( !glm.equals( gl_fitch_bc ) ) {
2373 catch ( final Exception e ) {
2374 e.printStackTrace( System.out );
2380 private static boolean testDirectednessAndAdjacency() {
2382 final Protein one_1 = new BasicProtein( "one", "1", 0 );
2383 final Protein two_1 = new BasicProtein( "two", "1", 0 );
2384 final Protein three_1 = new BasicProtein( "three", "1", 0 );
2385 final Protein four_1 = new BasicProtein( "four", "1", 0 );
2386 final Protein five_1 = new BasicProtein( "five", "1", 0 );
2387 one_1.addProteinDomain( new BasicDomain( "B", 12, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2388 one_1.addProteinDomain( new BasicDomain( "C", 13, 14, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2389 one_1.addProteinDomain( new BasicDomain( "A", 11, 12, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2390 one_1.addProteinDomain( new BasicDomain( "X", 100, 110, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2391 one_1.addProteinDomain( new BasicDomain( "Y", 200, 210, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2392 two_1.addProteinDomain( new BasicDomain( "A", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2393 two_1.addProteinDomain( new BasicDomain( "B", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2394 two_1.addProteinDomain( new BasicDomain( "Y", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2395 two_1.addProteinDomain( new BasicDomain( "X", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2396 three_1.addProteinDomain( new BasicDomain( "P", 10, 11, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2397 three_1.addProteinDomain( new BasicDomain( "M", 1, 2, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2398 three_1.addProteinDomain( new BasicDomain( "M", 5, 6, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2399 three_1.addProteinDomain( new BasicDomain( "N", 7, 8, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2400 three_1.addProteinDomain( new BasicDomain( "N", 3, 4, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2401 four_1.addProteinDomain( new BasicDomain( "XX", 10, 20, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2402 five_1.addProteinDomain( new BasicDomain( "YY", 30, 40, ( short ) 1, ( short ) 4, 0.1, -12 ) );
2403 final List<Protein> list_1 = new ArrayList<Protein>();
2404 list_1.add( one_1 );
2405 list_1.add( two_1 );
2406 list_1.add( three_1 );
2407 list_1.add( four_1 );
2408 list_1.add( five_1 );
2409 final GenomeWideCombinableDomains gwcd_1 = BasicGenomeWideCombinableDomains
2410 .createInstance( list_1, false, new BasicSpecies( "1" ), DomainCombinationType.DIRECTED_ADJACTANT );
2411 if ( !gwcd_1.toBinaryDomainCombinations()
2412 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "B" ) ) ) {
2415 if ( gwcd_1.toBinaryDomainCombinations()
2416 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "A" ) ) ) {
2419 if ( gwcd_1.toBinaryDomainCombinations()
2420 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "A" ) ) ) {
2423 if ( gwcd_1.toBinaryDomainCombinations()
2424 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "C" ) ) ) {
2427 if ( gwcd_1.toBinaryDomainCombinations()
2428 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "A" ) ) ) {
2431 if ( !gwcd_1.toBinaryDomainCombinations()
2432 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "C" ) ) ) {
2435 if ( !gwcd_1.toBinaryDomainCombinations()
2436 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "X" ) ) ) {
2439 if ( gwcd_1.toBinaryDomainCombinations()
2440 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "Y" ) ) ) {
2443 if ( !gwcd_1.toBinaryDomainCombinations()
2444 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2447 if ( gwcd_1.toBinaryDomainCombinations()
2448 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2451 if ( gwcd_1.toBinaryDomainCombinations()
2452 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2455 if ( !gwcd_1.toBinaryDomainCombinations()
2456 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "A" ) ) ) {
2459 if ( gwcd_1.toBinaryDomainCombinations()
2460 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "A" ) ) ) {
2463 if ( gwcd_1.toBinaryDomainCombinations()
2464 .contains( new AdjactantDirectedBinaryDomainCombination( "C", "B" ) ) ) {
2467 if ( !gwcd_1.toBinaryDomainCombinations()
2468 .contains( new AdjactantDirectedBinaryDomainCombination( "X", "Y" ) ) ) {
2471 if ( gwcd_1.toBinaryDomainCombinations()
2472 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "X" ) ) ) {
2475 if ( gwcd_1.toBinaryDomainCombinations()
2476 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "Y" ) ) ) {
2479 if ( gwcd_1.toBinaryDomainCombinations()
2480 .contains( new AdjactantDirectedBinaryDomainCombination( "A", "X" ) ) ) {
2483 if ( gwcd_1.toBinaryDomainCombinations()
2484 .contains( new AdjactantDirectedBinaryDomainCombination( "Y", "C" ) ) ) {
2487 if ( !gwcd_1.toBinaryDomainCombinations()
2488 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "N" ) ) ) {
2491 if ( !gwcd_1.toBinaryDomainCombinations()
2492 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "M" ) ) ) {
2495 if ( !gwcd_1.toBinaryDomainCombinations()
2496 .contains( new AdjactantDirectedBinaryDomainCombination( "N", "P" ) ) ) {
2499 if ( gwcd_1.toBinaryDomainCombinations()
2500 .contains( new AdjactantDirectedBinaryDomainCombination( "M", "P" ) ) ) {
2503 if ( gwcd_1.toBinaryDomainCombinations()
2504 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "N" ) ) ) {
2507 if ( gwcd_1.toBinaryDomainCombinations()
2508 .contains( new AdjactantDirectedBinaryDomainCombination( "P", "M" ) ) ) {
2511 if ( gwcd_1.toBinaryDomainCombinations()
2512 .contains( new AdjactantDirectedBinaryDomainCombination( "XX", "YY" ) ) ) {
2515 if ( gwcd_1.toBinaryDomainCombinations()
2516 .contains( new AdjactantDirectedBinaryDomainCombination( "YY", "XX" ) ) ) {
2519 if ( gwcd_1.toBinaryDomainCombinations()
2520 .contains( new AdjactantDirectedBinaryDomainCombination( "B", "B" ) ) ) {
2524 catch ( final Exception e ) {
2525 e.printStackTrace( System.out );
2531 private static boolean testDomainArchitectureBasedGenomeSimilarityCalculator() {
2533 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2534 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2535 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2536 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2537 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2538 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2539 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2540 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2541 final Domain i = new BasicDomain( "i", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2542 final Domain j = new BasicDomain( "j", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2543 final Domain k = new BasicDomain( "k", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2544 final Domain l = new BasicDomain( "l", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2545 final Domain m = new BasicDomain( "m", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2546 final Domain n = new BasicDomain( "n", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
2547 final Protein eel_0 = new BasicProtein( "0", "eel", 0 );
2548 final Protein eel_1 = new BasicProtein( "1", "eel", 0 );
2549 final Protein eel_2 = new BasicProtein( "2", "eel", 0 );
2550 final Protein eel_3 = new BasicProtein( "3", "eel", 0 );
2551 final Protein eel_4 = new BasicProtein( "4", "eel", 0 );
2552 final Protein eel_5 = new BasicProtein( "5", "eel", 0 );
2553 final Protein eel_6 = new BasicProtein( "6", "eel", 0 );
2554 final Protein rat_0 = new BasicProtein( "0", "rat", 0 );
2555 final Protein rat_1 = new BasicProtein( "1", "rat", 0 );
2556 final Protein rat_2 = new BasicProtein( "2", "rat", 0 );
2557 final Protein rat_3 = new BasicProtein( "3", "rat", 0 );
2558 final Protein rat_4 = new BasicProtein( "4", "rat", 0 );
2559 final Protein rat_5 = new BasicProtein( "5", "rat", 0 );
2560 final Protein rat_6 = new BasicProtein( "6", "rat", 0 );
2561 final Protein rat_7 = new BasicProtein( "7", "rat", 0 );
2562 eel_1.addProteinDomain( a );
2563 eel_2.addProteinDomain( a );
2564 eel_2.addProteinDomain( b );
2565 eel_3.addProteinDomain( a );
2566 eel_3.addProteinDomain( a );
2567 eel_3.addProteinDomain( b );
2568 eel_4.addProteinDomain( a );
2569 eel_4.addProteinDomain( b );
2570 eel_4.addProteinDomain( c );
2571 eel_4.addProteinDomain( d );
2572 eel_4.addProteinDomain( e );
2573 eel_5.addProteinDomain( e );
2574 eel_5.addProteinDomain( e );
2575 eel_5.addProteinDomain( f );
2576 eel_5.addProteinDomain( f );
2577 eel_5.addProteinDomain( f );
2578 eel_5.addProteinDomain( f );
2579 eel_6.addProteinDomain( g );
2580 eel_6.addProteinDomain( h );
2581 rat_1.addProteinDomain( a );
2582 rat_2.addProteinDomain( a );
2583 rat_2.addProteinDomain( b );
2584 rat_3.addProteinDomain( a );
2585 rat_3.addProteinDomain( a );
2586 rat_3.addProteinDomain( b );
2587 rat_4.addProteinDomain( a );
2588 rat_4.addProteinDomain( b );
2589 rat_4.addProteinDomain( c );
2590 rat_4.addProteinDomain( i );
2591 rat_4.addProteinDomain( l );
2592 rat_5.addProteinDomain( i );
2593 rat_5.addProteinDomain( f );
2594 rat_5.addProteinDomain( f );
2595 rat_6.addProteinDomain( j );
2596 rat_6.addProteinDomain( k );
2597 rat_7.addProteinDomain( m );
2598 rat_7.addProteinDomain( n );
2599 final List<Protein> protein_list_eel = new ArrayList<Protein>();
2600 protein_list_eel.add( eel_0 );
2601 protein_list_eel.add( eel_1 );
2602 protein_list_eel.add( eel_2 );
2603 protein_list_eel.add( eel_3 );
2604 protein_list_eel.add( eel_4 );
2605 protein_list_eel.add( eel_5 );
2606 protein_list_eel.add( eel_6 );
2607 final List<Protein> protein_list_rat = new ArrayList<Protein>();
2608 protein_list_rat.add( rat_0 );
2609 protein_list_rat.add( rat_1 );
2610 protein_list_rat.add( rat_2 );
2611 protein_list_rat.add( rat_3 );
2612 protein_list_rat.add( rat_4 );
2613 protein_list_rat.add( rat_5 );
2614 protein_list_rat.add( rat_6 );
2615 protein_list_rat.add( rat_7 );
2616 final GenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
2617 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
2618 final GenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
2619 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
2620 final GenomeWideCombinableDomains rat_not_ignore = BasicGenomeWideCombinableDomains
2621 .createInstance( protein_list_rat, false, new BasicSpecies( "rat" ) );
2622 final GenomeWideCombinableDomains rat_ignore = BasicGenomeWideCombinableDomains
2623 .createInstance( protein_list_rat, true, new BasicSpecies( "rat" ) );
2624 final DomainArchitectureBasedGenomeSimilarityCalculator calc_ni = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_not_ignore,
2626 final DomainArchitectureBasedGenomeSimilarityCalculator calc_i = new DomainArchitectureBasedGenomeSimilarityCalculator( eel_ignore,
2628 if ( calc_ni.getAllDomains().size() != 14 ) {
2631 if ( calc_i.getAllDomains().size() != 14 ) {
2634 if ( calc_ni.getDomainsSpecificToGenome0().size() != 4 ) {
2637 if ( calc_i.getDomainsSpecificToGenome0().size() != 4 ) {
2640 if ( calc_ni.getDomainsSpecificToGenome1().size() != 6 ) {
2643 if ( calc_i.getDomainsSpecificToGenome1().size() != 6 ) {
2646 if ( calc_i.getSharedDomains().size() != 4 ) {
2649 if ( calc_ni.getSharedDomains().size() != 4 ) {
2652 if ( !calc_ni.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
2655 if ( !calc_ni.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
2658 if ( !calc_ni.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
2661 if ( !calc_ni.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
2664 if ( calc_ni.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
2667 if ( calc_ni.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
2670 if ( !calc_i.getDomainsSpecificToGenome0().contains( d.getDomainId() ) ) {
2673 if ( !calc_i.getDomainsSpecificToGenome0().contains( e.getDomainId() ) ) {
2676 if ( !calc_i.getDomainsSpecificToGenome0().contains( g.getDomainId() ) ) {
2679 if ( !calc_i.getDomainsSpecificToGenome0().contains( h.getDomainId() ) ) {
2682 if ( calc_i.getDomainsSpecificToGenome0().contains( a.getDomainId() ) ) {
2685 if ( calc_i.getDomainsSpecificToGenome0().contains( i.getDomainId() ) ) {
2688 if ( !calc_ni.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
2691 if ( !calc_ni.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
2694 if ( !calc_ni.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
2697 if ( !calc_ni.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
2700 if ( !calc_ni.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
2703 if ( !calc_ni.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
2706 if ( calc_ni.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
2709 if ( calc_ni.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
2712 if ( calc_ni.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
2715 if ( !calc_i.getDomainsSpecificToGenome1().contains( i.getDomainId() ) ) {
2718 if ( !calc_i.getDomainsSpecificToGenome1().contains( l.getDomainId() ) ) {
2721 if ( !calc_i.getDomainsSpecificToGenome1().contains( j.getDomainId() ) ) {
2724 if ( !calc_i.getDomainsSpecificToGenome1().contains( k.getDomainId() ) ) {
2727 if ( !calc_i.getDomainsSpecificToGenome1().contains( m.getDomainId() ) ) {
2730 if ( !calc_i.getDomainsSpecificToGenome1().contains( n.getDomainId() ) ) {
2733 if ( calc_i.getDomainsSpecificToGenome1().contains( a.getDomainId() ) ) {
2736 if ( calc_i.getDomainsSpecificToGenome1().contains( b.getDomainId() ) ) {
2739 if ( calc_i.getDomainsSpecificToGenome1().contains( d.getDomainId() ) ) {
2742 if ( !calc_i.getSharedDomains().contains( a.getDomainId() ) ) {
2745 if ( !calc_i.getSharedDomains().contains( b.getDomainId() ) ) {
2748 if ( !calc_i.getSharedDomains().contains( c.getDomainId() ) ) {
2751 if ( !calc_i.getSharedDomains().contains( f.getDomainId() ) ) {
2754 final Set<DomainId> all = calc_ni.getAllDomains();
2755 if ( !all.contains( a.getDomainId() ) ) {
2758 if ( !all.contains( b.getDomainId() ) ) {
2761 if ( !all.contains( c.getDomainId() ) ) {
2764 if ( !all.contains( d.getDomainId() ) ) {
2767 if ( !all.contains( e.getDomainId() ) ) {
2770 if ( !all.contains( f.getDomainId() ) ) {
2773 if ( !all.contains( g.getDomainId() ) ) {
2776 if ( !all.contains( h.getDomainId() ) ) {
2779 if ( !all.contains( i.getDomainId() ) ) {
2782 if ( !all.contains( l.getDomainId() ) ) {
2785 if ( !all.contains( j.getDomainId() ) ) {
2788 if ( !all.contains( k.getDomainId() ) ) {
2791 if ( !all.contains( m.getDomainId() ) ) {
2794 if ( !all.contains( n.getDomainId() ) ) {
2797 final Set<BinaryDomainCombination> s_0_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome0();
2798 final Set<BinaryDomainCombination> s_0_i = calc_i.getBinaryDomainCombinationsSpecificToGenome0();
2799 final Set<BinaryDomainCombination> s_1_ni = calc_ni.getBinaryDomainCombinationsSpecificToGenome1();
2800 final Set<BinaryDomainCombination> s_1_i = calc_i.getBinaryDomainCombinationsSpecificToGenome1();
2801 final Set<BinaryDomainCombination> a_ni = calc_ni.getAllBinaryDomainCombinations();
2802 final Set<BinaryDomainCombination> a_i = calc_i.getAllBinaryDomainCombinations();
2803 final Set<BinaryDomainCombination> shared_ni = calc_ni.getSharedBinaryDomainCombinations();
2804 final Set<BinaryDomainCombination> shared_i = calc_i.getSharedBinaryDomainCombinations();
2805 if ( a_ni.size() != 25 ) {
2808 if ( a_i.size() != 22 ) {
2811 if ( s_0_ni.size() != 10 ) {
2814 if ( s_0_i.size() != 9 ) {
2817 if ( s_1_ni.size() != 10 ) {
2820 if ( s_1_i.size() != 10 ) {
2823 if ( shared_ni.size() != 5 ) {
2826 if ( shared_i.size() != 3 ) {
2829 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
2832 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
2835 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
2838 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
2841 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
2844 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
2847 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
2850 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
2853 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
2856 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
2859 if ( !a_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
2862 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
2865 if ( !a_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
2868 if ( !a_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
2871 if ( !a_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
2874 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
2877 if ( !a_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
2880 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
2883 if ( !a_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
2886 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
2889 if ( !a_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
2892 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "l" ) ) ) {
2895 if ( !a_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
2898 if ( !a_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
2901 if ( !a_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
2904 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
2907 if ( a_ni.contains( new BasicBinaryDomainCombination( "a", "m" ) ) ) {
2910 if ( a_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
2913 if ( a_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
2916 if ( a_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
2919 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
2922 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
2925 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
2928 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
2931 if ( !shared_ni.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
2934 if ( shared_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
2937 if ( shared_i.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
2940 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
2943 if ( !shared_i.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
2946 if ( !shared_i.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
2949 if ( shared_i.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
2952 if ( shared_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
2955 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
2958 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
2961 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
2964 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
2967 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
2970 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
2973 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
2976 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
2979 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
2982 if ( !s_0_ni.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
2985 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
2988 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
2991 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
2994 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
2997 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
3000 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
3003 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
3006 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
3009 if ( !s_0_i.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
3012 if ( s_0_i.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
3015 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3018 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3021 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3024 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3027 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3030 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3033 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3036 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3039 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3042 if ( !s_1_ni.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3045 if ( s_1_ni.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3048 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "i" ) ) ) {
3051 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "a", "l" ) ) ) {
3054 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "i" ) ) ) {
3057 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "b", "l" ) ) ) {
3060 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "i" ) ) ) {
3063 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "c", "l" ) ) ) {
3066 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "l", "i" ) ) ) {
3069 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "i", "f" ) ) ) {
3072 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "m", "n" ) ) ) {
3075 if ( !s_1_i.contains( new BasicBinaryDomainCombination( "j", "k" ) ) ) {
3078 if ( s_1_i.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
3081 if ( !isEqual( calc_ni.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3082 1.0 - ( ( 25.0 - 5.0 ) / 25.0 ) ) ) {
3085 if ( !isEqual( calc_i.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3086 1.0 - ( ( 22.0 - 3.0 ) / 22.0 ) ) ) {
3089 if ( !isEqual( calc_ni.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 14.0 - 4.0 ) / 14.0 ) ) ) {
3092 if ( !isEqual( calc_i.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 14.0 - 4.0 ) / 14.0 ) ) ) {
3095 final Domain u = new BasicDomain( "u", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3096 final Domain v = new BasicDomain( "v", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3097 final Domain w = new BasicDomain( "w", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3098 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3099 final Domain y = new BasicDomain( "y", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3100 final Domain z = new BasicDomain( "z", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
3101 final Protein a_0 = new BasicProtein( "0", "a", 0 );
3102 final Protein a_1 = new BasicProtein( "1", "a", 0 );
3103 final Protein a_2 = new BasicProtein( "2", "a", 0 );
3104 final Protein b_0 = new BasicProtein( "0", "b", 0 );
3105 final Protein b_1 = new BasicProtein( "1", "b", 0 );
3106 a_0.addProteinDomain( u );
3107 a_0.addProteinDomain( v );
3108 a_0.addProteinDomain( w );
3109 a_1.addProteinDomain( w );
3110 a_1.addProteinDomain( x );
3111 a_2.addProteinDomain( y );
3112 a_2.addProteinDomain( z );
3113 b_0.addProteinDomain( u );
3114 b_0.addProteinDomain( w );
3115 b_1.addProteinDomain( y );
3116 b_1.addProteinDomain( z );
3117 final List<Protein> protein_list_a = new ArrayList<Protein>();
3118 protein_list_a.add( a_0 );
3119 protein_list_a.add( a_1 );
3120 protein_list_a.add( a_2 );
3121 final List<Protein> protein_list_b = new ArrayList<Protein>();
3122 protein_list_b.add( b_0 );
3123 protein_list_b.add( b_1 );
3124 final GenomeWideCombinableDomains ca = BasicGenomeWideCombinableDomains
3125 .createInstance( protein_list_a, false, new BasicSpecies( "a" ) );
3126 final GenomeWideCombinableDomains cb = BasicGenomeWideCombinableDomains
3127 .createInstance( protein_list_b, true, new BasicSpecies( "b" ) );
3128 final DomainArchitectureBasedGenomeSimilarityCalculator calc_u = new DomainArchitectureBasedGenomeSimilarityCalculator( ca,
3130 calc_u.setAllowDomainsToBeIgnored( true );
3131 if ( calc_u.getAllDomains().size() != 6 ) {
3134 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3137 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3140 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3143 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3146 if ( calc_u.getSharedDomains().size() != 4 ) {
3149 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3152 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3155 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3158 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3161 if ( calc_u.getAllDomains().size() != 6 ) {
3164 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3167 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3170 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3173 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3176 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3179 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3182 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 3 ) {
3185 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3188 if ( calc_u.getSharedBinaryDomainCombinations().size() != 2 ) {
3191 if ( calc_u.getAllBinaryDomainCombinations().size() != 5 ) {
3194 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3195 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3198 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3199 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3202 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3203 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3206 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3209 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3212 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3215 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3218 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3221 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3224 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3227 calc_u.setAllowDomainsToBeIgnored( true );
3228 calc_u.addDomainIdToIgnore( u.getDomainId() );
3229 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3230 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3231 if ( calc_u.getAllDomains().size() != 5 ) {
3234 if ( calc_u.getDomainsSpecificToGenome0().size() != 2 ) {
3237 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3240 if ( !calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3243 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3246 if ( calc_u.getSharedDomains().size() != 3 ) {
3249 if ( calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3252 if ( !calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3255 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3258 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3261 if ( calc_u.getAllDomains().size() != 5 ) {
3264 if ( calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3267 if ( !calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3270 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3273 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3276 if ( !calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3279 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3282 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 2 ) {
3285 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3288 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3291 if ( calc_u.getAllBinaryDomainCombinations().size() != 3 ) {
3294 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3295 .contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3298 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3299 .contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3302 if ( !calc_u.getBinaryDomainCombinationsSpecificToGenome0()
3303 .contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3306 if ( calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3309 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3312 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "v", "u" ) ) ) {
3315 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "v" ) ) ) {
3318 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "x" ) ) ) {
3321 if ( calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "w", "u" ) ) ) {
3324 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3327 calc_u.setAllowDomainsToBeIgnored( false );
3328 if ( calc_u.getAllDomains().size() != 6 ) {
3332 calc_u.setAllowDomainsToBeIgnored( true );
3333 calc_u.deleteAllDomainIdsToIgnore();
3334 calc_u.addDomainIdToIgnore( new DomainId( "v" ) );
3335 calc_u.addDomainIdToIgnore( new DomainId( "w" ) );
3336 calc_u.addDomainIdToIgnore( new DomainId( "other" ) );
3337 calc_u.addDomainIdToIgnore( new DomainId( "other_too" ) );
3338 if ( calc_u.getAllDomains().size() != 4 ) {
3341 if ( calc_u.getDomainsSpecificToGenome0().size() != 1 ) {
3344 if ( calc_u.getDomainsSpecificToGenome1().size() != 0 ) {
3347 if ( calc_u.getDomainsSpecificToGenome0().contains( v.getDomainId() ) ) {
3350 if ( !calc_u.getDomainsSpecificToGenome0().contains( x.getDomainId() ) ) {
3353 if ( calc_u.getSharedDomains().size() != 3 ) {
3356 if ( !calc_u.getSharedDomains().contains( u.getDomainId() ) ) {
3359 if ( calc_u.getSharedDomains().contains( w.getDomainId() ) ) {
3362 if ( !calc_u.getSharedDomains().contains( y.getDomainId() ) ) {
3365 if ( !calc_u.getSharedDomains().contains( z.getDomainId() ) ) {
3368 if ( calc_u.getAllDomains().size() != 4 ) {
3371 if ( !calc_u.getAllDomains().contains( u.getDomainId() ) ) {
3374 if ( calc_u.getAllDomains().contains( w.getDomainId() ) ) {
3377 if ( !calc_u.getAllDomains().contains( y.getDomainId() ) ) {
3380 if ( !calc_u.getAllDomains().contains( z.getDomainId() ) ) {
3383 if ( calc_u.getAllDomains().contains( v.getDomainId() ) ) {
3386 if ( !calc_u.getAllDomains().contains( x.getDomainId() ) ) {
3389 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome0().size() != 0 ) {
3392 if ( calc_u.getBinaryDomainCombinationsSpecificToGenome1().size() != 0 ) {
3395 if ( calc_u.getSharedBinaryDomainCombinations().size() != 1 ) {
3398 if ( calc_u.getAllBinaryDomainCombinations().size() != 1 ) {
3401 if ( !calc_u.getSharedBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "y", "z" ) ) ) {
3404 if ( !calc_u.getAllBinaryDomainCombinations().contains( new BasicBinaryDomainCombination( "z", "y" ) ) ) {
3407 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3408 1.0 - ( ( 1.0 - 1.0 ) / 1.0 ) ) ) {
3411 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 4.0 - 3.0 ) / 4.0 ) ) ) {
3414 calc_u.setAllowDomainsToBeIgnored( false );
3415 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3416 1.0 - ( ( 5.0 - 2.0 ) / 5.0 ) ) ) {
3419 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 6.0 - 4.0 ) / 6.0 ) ) ) {
3422 calc_u.setAllowDomainsToBeIgnored( true );
3423 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3424 1.0 - ( ( 1.0 - 1.0 ) / 1.0 ) ) ) {
3427 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 4.0 - 3.0 ) / 4.0 ) ) ) {
3430 calc_u.deleteAllDomainIdsToIgnore();
3431 if ( !isEqual( calc_u.calculateSharedBinaryDomainCombinationBasedGenomeSimilarityScore(),
3432 1.0 - ( ( 5.0 - 2.0 ) / 5.0 ) ) ) {
3435 if ( !isEqual( calc_u.calculateSharedDomainsBasedGenomeSimilarityScore(), 1.0 - ( ( 6.0 - 4.0 ) / 6.0 ) ) ) {
3439 catch ( final Exception e ) {
3440 e.printStackTrace( System.out );
3446 private static boolean testDomainCombinationCounting( final File test_dir ) {
3448 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
3449 + ForesterUtil.getFileSeparator() + "hmmpfam_output2" ), "human", "ls" );
3450 parser.setEValueMaximum( 0.2 );
3451 parser.setIgnoreDufs( true );
3452 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
3453 final List<Protein> domain_collections = parser.parse();
3454 final BasicGenomeWideCombinableDomains cdcc = BasicGenomeWideCombinableDomains
3455 .createInstance( domain_collections, false, new BasicSpecies( "human" ) );
3456 CombinableDomains cd = cdcc.get( new DomainId( "A" ) );
3457 if ( cd.getKeyDomainCount() != 9 ) {
3460 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3463 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3466 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 2 ) {
3469 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
3472 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3475 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3478 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3481 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3484 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3487 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3490 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3493 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3496 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3499 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3502 if ( cd.getKeyDomainCount() != 9 ) {
3505 cd = cdcc.get( new DomainId( "B" ) );
3506 if ( cd.getKeyDomainCount() != 12 ) {
3509 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3512 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3515 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 6 ) {
3518 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3521 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3524 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3527 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3530 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3533 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3536 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3539 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 1 ) {
3542 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 1 ) {
3545 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 1 ) {
3548 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3551 if ( cd.getKeyDomainCount() != 12 ) {
3554 cd = cdcc.get( new DomainId( "C" ) );
3555 if ( cd.getKeyDomainCount() != 10 ) {
3558 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3561 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3564 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 4 ) {
3567 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 4 ) {
3570 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 2 ) {
3573 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3576 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3579 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "U" ).getDomainId() ) != 1 ) {
3582 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "V" ).getDomainId() ) != 1 ) {
3585 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "W" ).getDomainId() ) != 1 ) {
3588 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "X" ).getDomainId() ) != 2 ) {
3591 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Y" ).getDomainId() ) != 2 ) {
3594 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "Z" ).getDomainId() ) != 2 ) {
3597 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3600 cd = cdcc.get( new DomainId( "D" ) );
3601 if ( cd.getKeyDomainCount() != 15 ) {
3604 if ( cd.getKeyDomainProteinsCount() != 6 ) {
3607 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3610 cd = cdcc.get( new DomainId( "E" ) );
3611 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3614 if ( cd.getKeyDomainCount() != 1 ) {
3617 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3620 cd = cdcc.get( new DomainId( "U" ) );
3621 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3624 if ( cd.getKeyDomainCount() != 6 ) {
3627 if ( cd.getKeyDomainProteinsCount() != 3 ) {
3630 cd = cdcc.get( new DomainId( "V" ) );
3631 if ( cd.getNumberOfCombinableDomains() != 11 ) {
3634 if ( cd.getKeyDomainCount() != 3 ) {
3637 if ( cd.getKeyDomainProteinsCount() != 2 ) {
3640 cd = cdcc.get( new DomainId( "W" ) );
3641 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3644 if ( cd.getKeyDomainCount() != 2 ) {
3647 if ( cd.getKeyDomainProteinsCount() != 2 ) {
3650 cd = cdcc.get( new DomainId( "X" ) );
3651 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3654 if ( cd.getKeyDomainCount() != 2 ) {
3657 cd = cdcc.get( new DomainId( "Y" ) );
3658 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3661 cd = cdcc.get( new DomainId( "Z" ) );
3662 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3665 cd = cdcc.get( new DomainId( "NN" ) );
3666 if ( cd.getKeyDomainCount() != 1 ) {
3669 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3672 if ( cd.getNumberOfCombinableDomains() != 0 ) {
3675 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "NN" ).getDomainId() ) != 0 ) {
3678 cd = cdcc.get( new DomainId( "MM" ) );
3679 if ( cd.getNumberOfCombinableDomains() != 1 ) {
3682 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 0 ) {
3685 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
3688 cd = cdcc.get( new DomainId( "OO" ) );
3689 if ( cd.getNumberOfCombinableDomains() != 2 ) {
3692 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "OO" ).getDomainId() ) != 1 ) {
3695 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "MM" ).getDomainId() ) != 1 ) {
3698 cd = cdcc.get( new DomainId( "QQ" ) );
3699 if ( cd.getNumberOfCombinableDomains() != 1 ) {
3702 if ( cd.getKeyDomainCount() != 17 ) {
3705 if ( cd.getKeyDomainProteinsCount() != 4 ) {
3708 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "QQ" ).getDomainId() ) != 3 ) {
3711 cd = cdcc.get( new DomainId( "PP" ) );
3712 if ( cd.getNumberOfCombinableDomains() != 0 ) {
3715 if ( cd.getKeyDomainCount() != 2 ) {
3718 if ( cd.getKeyDomainProteinsCount() != 2 ) {
3721 cd = cdcc.get( new DomainId( "singlet" ) );
3722 if ( cd.getKeyDomainCount() != 1 ) {
3725 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3728 if ( cd.getNumberOfCombinableDomains() != 0 ) {
3731 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "singlet" ).getDomainId() ) != 0 ) {
3734 cd = cdcc.get( new DomainId( "three" ) );
3735 if ( cd.getKeyDomainCount() != 3 ) {
3738 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3741 if ( cd.getNumberOfCombinableDomains() != 1 ) {
3744 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 1 ) {
3747 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
3750 // Ignore combinations with same:
3751 final BasicGenomeWideCombinableDomains cdcc2 = BasicGenomeWideCombinableDomains
3752 .createInstance( domain_collections,
3754 new BasicSpecies( "human" ),
3756 DomainCombinationType.BASIC,
3759 cd = cdcc2.get( new DomainId( "A" ) );
3760 if ( cd.getKeyDomainCount() != 9 ) {
3763 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3766 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3769 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "A" ).getDomainId() ) != 0 ) {
3772 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "B" ).getDomainId() ) != 6 ) {
3775 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "C" ).getDomainId() ) != 4 ) {
3778 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "D" ).getDomainId() ) != 3 ) {
3781 if ( cd.getNumberOfProteinsExhibitingCombination( new SimpleDomain( "E" ).getDomainId() ) != 1 ) {
3784 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
3787 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
3790 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
3793 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
3796 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
3799 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
3802 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
3805 cd = cdcc2.get( new DomainId( "B" ) );
3806 if ( cd.getKeyDomainCount() != 12 ) {
3809 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3812 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3815 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 6 ) {
3818 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 0 ) {
3821 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 4 ) {
3824 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
3827 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
3830 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
3833 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
3836 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
3839 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 1 ) {
3842 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 1 ) {
3845 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 1 ) {
3848 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
3851 cd = cdcc2.get( new DomainId( "C" ) );
3852 if ( cd.getKeyDomainCount() != 10 ) {
3855 if ( cd.getKeyDomainProteinsCount() != 7 ) {
3858 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3861 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "A" ) ) != 4 ) {
3864 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "B" ) ) != 4 ) {
3867 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "C" ) ) != 0 ) {
3870 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "D" ) ) != 3 ) {
3873 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "E" ) ) != 1 ) {
3876 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "U" ) ) != 1 ) {
3879 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "V" ) ) != 1 ) {
3882 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "W" ) ) != 1 ) {
3885 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "X" ) ) != 2 ) {
3888 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Y" ) ) != 2 ) {
3891 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "Z" ) ) != 2 ) {
3894 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
3897 cd = cdcc2.get( new DomainId( "D" ) );
3898 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3901 cd = cdcc2.get( new DomainId( "E" ) );
3902 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3905 if ( cd.getKeyDomainCount() != 1 ) {
3908 cd = cdcc2.get( new DomainId( "U" ) );
3909 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3912 cd = cdcc2.get( new DomainId( "V" ) );
3913 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3916 cd = cdcc2.get( new DomainId( "W" ) );
3917 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3920 cd = cdcc2.get( new DomainId( "X" ) );
3921 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3924 cd = cdcc2.get( new DomainId( "Y" ) );
3925 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3928 cd = cdcc2.get( new DomainId( "Z" ) );
3929 if ( cd.getNumberOfCombinableDomains() != 10 ) {
3932 cd = cdcc2.get( new DomainId( "NN" ) );
3933 if ( cd.getNumberOfCombinableDomains() != 0 ) {
3936 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "NN" ) ) != 0 ) {
3939 cd = cdcc2.get( new DomainId( "MM" ) );
3940 if ( cd.getNumberOfCombinableDomains() != 1 ) {
3943 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 0 ) {
3946 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 1 ) {
3949 cd = cdcc2.get( new DomainId( "OO" ) );
3950 if ( cd.getNumberOfCombinableDomains() != 1 ) {
3953 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "OO" ) ) != 0 ) {
3956 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "MM" ) ) != 1 ) {
3959 cd = cdcc2.get( new DomainId( "QQ" ) );
3960 if ( cd.getNumberOfCombinableDomains() != 0 ) {
3963 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "QQ" ) ) != 0 ) {
3966 cd = cdcc2.get( new DomainId( "singlet" ) );
3967 if ( cd.getKeyDomainCount() != 1 ) {
3970 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3973 if ( cd.getNumberOfCombinableDomains() != 0 ) {
3976 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "singlet" ) ) != 0 ) {
3979 cd = cdcc2.get( new DomainId( "three" ) );
3980 if ( cd.getKeyDomainCount() != 3 ) {
3983 if ( cd.getKeyDomainProteinsCount() != 1 ) {
3986 if ( cd.getNumberOfCombinableDomains() != 0 ) {
3989 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "three" ) ) != 0 ) {
3992 if ( cd.getNumberOfProteinsExhibitingCombination( new DomainId( "so_far_so_bad" ) ) != 0 ) {
3996 catch ( final Exception e ) {
3997 e.printStackTrace( System.out );
4003 private static boolean testDomainSorting() {
4005 final Domain A = new BasicDomain( "A", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4006 final Domain B = new BasicDomain( "B", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.1, -12 );
4007 final Domain C = new BasicDomain( "C", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.2, -12 );
4008 final Domain D = new BasicDomain( "D", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.3, -12 );
4009 final Domain E = new BasicDomain( "E", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.4, -12 );
4010 final Domain F = new BasicDomain( "F", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.5, -12 );
4011 final Domain G = new BasicDomain( "G", ( short ) 1, ( short ) 2, ( short ) 1, ( short ) 1, 0.6, -12 );
4012 final Domain H1 = new BasicDomain( "H", ( short ) 100, ( short ) 200, ( short ) 1, ( short ) 5, 0.7, -12 );
4013 final Domain H2 = new BasicDomain( "H", ( short ) 300, ( short ) 400, ( short ) 2, ( short ) 5, 0.7, -12 );
4014 final Domain H3 = new BasicDomain( "H", ( short ) 500, ( short ) 600, ( short ) 3, ( short ) 5, 0.7, -12 );
4015 final Domain H4 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 4, ( short ) 5, 0.7, -12 );
4016 final Domain H5 = new BasicDomain( "H", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4017 final Domain H6 = new BasicDomain( "H",
4024 final Domain H7 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 5, 0.7, -12 );
4025 final Domain H8 = new BasicDomain( "H7", ( short ) 700, ( short ) 800, ( short ) 5, ( short ) 200, 0.7, -12 );
4026 final Protein protein = new BasicProtein( "00", "bat", 0 );
4027 protein.addProteinDomain( H5 );
4028 protein.addProteinDomain( H2 );
4029 protein.addProteinDomain( H7 );
4030 protein.addProteinDomain( H6 );
4031 protein.addProteinDomain( A );
4032 protein.addProteinDomain( G );
4033 protein.addProteinDomain( H4 );
4034 protein.addProteinDomain( D );
4035 protein.addProteinDomain( H1 );
4036 protein.addProteinDomain( C );
4037 protein.addProteinDomain( E );
4038 protein.addProteinDomain( F );
4039 protein.addProteinDomain( B );
4040 protein.addProteinDomain( H3 );
4041 protein.addProteinDomain( H7 );
4042 protein.addProteinDomain( H7 );
4043 protein.addProteinDomain( H8 );
4044 final List<Domain> sorted = SurfacingUtil.sortDomainsWithAscendingConfidenceValues( protein );
4045 if ( sorted.size() != 17 ) {
4048 if ( !sorted.get( 0 ).getDomainId().getId().equals( "A" ) ) {
4051 if ( sorted.get( 0 ).getNumber() != 1 ) {
4054 if ( !sorted.get( 1 ).getDomainId().getId().equals( "B" ) ) {
4057 if ( sorted.get( 1 ).getNumber() != 1 ) {
4060 if ( !sorted.get( 2 ).getDomainId().getId().equals( "C" ) ) {
4063 if ( sorted.get( 2 ).getNumber() != 1 ) {
4066 if ( !sorted.get( 3 ).getDomainId().getId().equals( "D" ) ) {
4069 if ( sorted.get( 3 ).getNumber() != 1 ) {
4072 if ( !sorted.get( 4 ).getDomainId().getId().equals( "E" ) ) {
4075 if ( sorted.get( 4 ).getNumber() != 1 ) {
4078 if ( !sorted.get( 5 ).getDomainId().getId().equals( "F" ) ) {
4081 if ( sorted.get( 5 ).getNumber() != 1 ) {
4084 if ( !sorted.get( 6 ).getDomainId().getId().equals( "G" ) ) {
4087 if ( sorted.get( 6 ).getNumber() != 1 ) {
4090 if ( !sorted.get( 7 ).getDomainId().getId().equals( "H" ) ) {
4093 if ( sorted.get( 7 ).getNumber() != 5 ) {
4096 if ( !sorted.get( 8 ).getDomainId().getId().equals( "H" ) ) {
4099 if ( sorted.get( 8 ).getNumber() != 2 ) {
4102 if ( !sorted.get( 9 ).getDomainId().getId().equals( "H" ) ) {
4105 if ( sorted.get( 9 ).getNumber() != 6 ) {
4108 if ( !sorted.get( 10 ).getDomainId().getId().equals( "H" ) ) {
4111 if ( sorted.get( 10 ).getNumber() != 4 ) {
4114 if ( !sorted.get( 11 ).getDomainId().getId().equals( "H" ) ) {
4117 if ( sorted.get( 11 ).getNumber() != 1 ) {
4120 if ( sorted.get( 11 ).getTotalCount() != 5 ) {
4123 if ( !sorted.get( 12 ).getDomainId().getId().equals( "H" ) ) {
4126 if ( sorted.get( 12 ).getNumber() != 3 ) {
4129 if ( !sorted.get( 13 ).getDomainId().getId().equals( "H7" ) ) {
4132 if ( sorted.get( 13 ).getNumber() != 5 ) {
4135 if ( !sorted.get( 14 ).getDomainId().getId().equals( "H7" ) ) {
4138 if ( sorted.get( 14 ).getNumber() != 5 ) {
4141 if ( !sorted.get( 15 ).getDomainId().getId().equals( "H7" ) ) {
4144 if ( sorted.get( 15 ).getNumber() != 5 ) {
4147 // To check if sorting is stable [as claimed by Sun for
4148 // Collections.sort( List )]
4149 if ( !sorted.get( 16 ).getDomainId().getId().equals( "H7" ) ) {
4152 if ( sorted.get( 16 ).getNumber() != 5 ) {
4155 if ( sorted.get( 16 ).getTotalCount() != 200 ) {
4159 catch ( final Exception e ) {
4160 e.printStackTrace( System.out );
4166 private static boolean testEngulfingOverlapRemoval() {
4168 final Domain d0 = new BasicDomain( "d0", 0, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4169 final Domain d1 = new BasicDomain( "d1", 0, 1, ( short ) 1, ( short ) 1, 0.1, 1 );
4170 final Domain d2 = new BasicDomain( "d2", 0, 2, ( short ) 1, ( short ) 1, 0.1, 1 );
4171 final Domain d3 = new BasicDomain( "d3", 7, 8, ( short ) 1, ( short ) 1, 0.1, 1 );
4172 final Domain d4 = new BasicDomain( "d4", 7, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4173 final Domain d5 = new BasicDomain( "d4", 0, 9, ( short ) 1, ( short ) 1, 0.1, 1 );
4174 final Domain d6 = new BasicDomain( "d4", 4, 5, ( short ) 1, ( short ) 1, 0.1, 1 );
4175 final List<Boolean> covered = new ArrayList<Boolean>();
4176 covered.add( true ); // 0
4177 covered.add( false ); // 1
4178 covered.add( true ); // 2
4179 covered.add( false ); // 3
4180 covered.add( true ); // 4
4181 covered.add( true ); // 5
4182 covered.add( false ); // 6
4183 covered.add( true ); // 7
4184 covered.add( true ); // 8
4185 if ( SurfacingUtil.isEngulfed( d0, covered ) ) {
4188 if ( SurfacingUtil.isEngulfed( d1, covered ) ) {
4191 if ( SurfacingUtil.isEngulfed( d2, covered ) ) {
4194 if ( !SurfacingUtil.isEngulfed( d3, covered ) ) {
4197 if ( SurfacingUtil.isEngulfed( d4, covered ) ) {
4200 if ( SurfacingUtil.isEngulfed( d5, covered ) ) {
4203 if ( !SurfacingUtil.isEngulfed( d6, covered ) ) {
4206 final Domain a = new BasicDomain( "a", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4207 final Domain b = new BasicDomain( "b", 8, 20, ( short ) 1, ( short ) 1, 0.2, 1 );
4208 final Domain c = new BasicDomain( "c", 15, 16, ( short ) 1, ( short ) 1, 0.3, 1 );
4209 final Protein abc = new BasicProtein( "abc", "nemve", 0 );
4210 abc.addProteinDomain( a );
4211 abc.addProteinDomain( b );
4212 abc.addProteinDomain( c );
4213 final Protein abc_r1 = SurfacingUtil.removeOverlappingDomains( 3, false, abc );
4214 final Protein abc_r2 = SurfacingUtil.removeOverlappingDomains( 3, true, abc );
4215 if ( abc.getNumberOfProteinDomains() != 3 ) {
4218 if ( abc_r1.getNumberOfProteinDomains() != 3 ) {
4221 if ( abc_r2.getNumberOfProteinDomains() != 2 ) {
4224 if ( !abc_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
4227 if ( !abc_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "b" ) ) {
4230 final Domain d = new BasicDomain( "d", 0, 10, ( short ) 1, ( short ) 1, 0.1, 1 );
4231 final Domain e = new BasicDomain( "e", 8, 20, ( short ) 1, ( short ) 1, 0.3, 1 );
4232 final Domain f = new BasicDomain( "f", 15, 16, ( short ) 1, ( short ) 1, 0.2, 1 );
4233 final Protein def = new BasicProtein( "def", "nemve", 0 );
4234 def.addProteinDomain( d );
4235 def.addProteinDomain( e );
4236 def.addProteinDomain( f );
4237 final Protein def_r1 = SurfacingUtil.removeOverlappingDomains( 5, false, def );
4238 final Protein def_r2 = SurfacingUtil.removeOverlappingDomains( 5, true, def );
4239 if ( def.getNumberOfProteinDomains() != 3 ) {
4242 if ( def_r1.getNumberOfProteinDomains() != 3 ) {
4245 if ( def_r2.getNumberOfProteinDomains() != 3 ) {
4248 if ( !def_r2.getProteinDomain( 0 ).getDomainId().getId().equals( "d" ) ) {
4251 if ( !def_r2.getProteinDomain( 1 ).getDomainId().getId().equals( "f" ) ) {
4254 if ( !def_r2.getProteinDomain( 2 ).getDomainId().getId().equals( "e" ) ) {
4258 catch ( final Exception e ) {
4259 e.printStackTrace( System.out );
4265 private static boolean testGenomeWideCombinableDomains() {
4267 final Domain a = new BasicDomain( "a", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4268 final Domain b = new BasicDomain( "b", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4269 final Domain c = new BasicDomain( "c", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4270 final Domain d = new BasicDomain( "d", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4271 final Domain e = new BasicDomain( "e", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4272 final Domain f = new BasicDomain( "f", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4273 final Domain g = new BasicDomain( "g", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4274 final Domain h = new BasicDomain( "h", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4275 final Domain x = new BasicDomain( "x", 23, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
4276 final Protein eel_0 = new BasicProtein( "0", "eel", 0 );
4277 final Protein eel_1 = new BasicProtein( "1", "eel", 0 );
4278 final Protein eel_2 = new BasicProtein( "2", "eel", 0 );
4279 final Protein eel_3 = new BasicProtein( "3", "eel", 0 );
4280 final Protein eel_4 = new BasicProtein( "4", "eel", 0 );
4281 final Protein eel_5 = new BasicProtein( "5", "eel", 0 );
4282 final Protein eel_6 = new BasicProtein( "6", "eel", 0 );
4283 eel_1.addProteinDomain( a );
4284 eel_2.addProteinDomain( a );
4285 eel_2.addProteinDomain( b );
4286 eel_3.addProteinDomain( a );
4287 eel_3.addProteinDomain( a );
4288 eel_3.addProteinDomain( b );
4289 eel_4.addProteinDomain( a );
4290 eel_4.addProteinDomain( b );
4291 eel_4.addProteinDomain( c );
4292 eel_4.addProteinDomain( d );
4293 eel_4.addProteinDomain( e );
4294 eel_5.addProteinDomain( e );
4295 eel_5.addProteinDomain( e );
4296 eel_5.addProteinDomain( f );
4297 eel_5.addProteinDomain( f );
4298 eel_5.addProteinDomain( f );
4299 eel_5.addProteinDomain( f );
4300 eel_6.addProteinDomain( g );
4301 eel_6.addProteinDomain( h );
4302 final List<Protein> protein_list_eel = new ArrayList<Protein>();
4303 protein_list_eel.add( eel_0 );
4304 protein_list_eel.add( eel_1 );
4305 protein_list_eel.add( eel_2 );
4306 protein_list_eel.add( eel_3 );
4307 protein_list_eel.add( eel_4 );
4308 protein_list_eel.add( eel_5 );
4309 protein_list_eel.add( eel_6 );
4310 final BasicGenomeWideCombinableDomains eel_not_ignore = BasicGenomeWideCombinableDomains
4311 .createInstance( protein_list_eel, false, new BasicSpecies( "eel" ) );
4312 final BasicGenomeWideCombinableDomains eel_ignore = BasicGenomeWideCombinableDomains
4313 .createInstance( protein_list_eel, true, new BasicSpecies( "eel" ) );
4314 if ( !eel_not_ignore.contains( new DomainId( "a" ) ) ) {
4317 if ( !eel_not_ignore.contains( new DomainId( "b" ) ) ) {
4320 if ( !eel_not_ignore.contains( new DomainId( "c" ) ) ) {
4323 if ( !eel_not_ignore.contains( new DomainId( "d" ) ) ) {
4326 if ( !eel_not_ignore.contains( new DomainId( "e" ) ) ) {
4329 if ( !eel_not_ignore.contains( new DomainId( "f" ) ) ) {
4332 if ( !eel_not_ignore.contains( new DomainId( "g" ) ) ) {
4335 if ( !eel_not_ignore.contains( new DomainId( "h" ) ) ) {
4338 if ( eel_not_ignore.contains( new DomainId( "x" ) ) ) {
4341 if ( !eel_ignore.contains( new DomainId( "a" ) ) ) {
4344 if ( !eel_ignore.contains( new DomainId( "b" ) ) ) {
4347 if ( !eel_ignore.contains( new DomainId( "c" ) ) ) {
4350 if ( !eel_ignore.contains( new DomainId( "d" ) ) ) {
4353 if ( !eel_ignore.contains( new DomainId( "e" ) ) ) {
4356 if ( !eel_ignore.contains( new DomainId( "f" ) ) ) {
4359 if ( !eel_ignore.contains( new DomainId( "g" ) ) ) {
4362 if ( !eel_ignore.contains( new DomainId( "h" ) ) ) {
4365 if ( eel_ignore.contains( new DomainId( "x" ) ) ) {
4368 if ( eel_not_ignore.getSize() != 8 ) {
4371 if ( eel_ignore.getSize() != 8 ) {
4374 if ( eel_not_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 5 ) {
4377 if ( eel_not_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4380 if ( eel_not_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4383 if ( eel_not_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4386 if ( eel_not_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 6 ) {
4389 if ( eel_not_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 2 ) {
4392 if ( eel_not_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4395 if ( eel_not_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4398 if ( eel_ignore.get( new DomainId( "a" ) ).getCombinableDomainsIds().size() != 4 ) {
4401 if ( eel_ignore.get( new DomainId( "b" ) ).getCombinableDomainsIds().size() != 4 ) {
4404 if ( eel_ignore.get( new DomainId( "c" ) ).getCombinableDomainsIds().size() != 4 ) {
4407 if ( eel_ignore.get( new DomainId( "d" ) ).getCombinableDomainsIds().size() != 4 ) {
4410 if ( eel_ignore.get( new DomainId( "e" ) ).getCombinableDomainsIds().size() != 5 ) {
4413 if ( eel_ignore.get( new DomainId( "f" ) ).getCombinableDomainsIds().size() != 1 ) {
4416 if ( eel_ignore.get( new DomainId( "g" ) ).getCombinableDomainsIds().size() != 1 ) {
4419 if ( eel_ignore.get( new DomainId( "h" ) ).getCombinableDomainsIds().size() != 1 ) {
4422 if ( eel_not_ignore.getAllDomainIds().size() != 8 ) {
4425 if ( !eel_not_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4428 if ( !eel_not_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4431 if ( !eel_not_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4434 if ( !eel_not_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4437 if ( !eel_not_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4440 if ( !eel_not_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4443 if ( !eel_not_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4446 if ( !eel_not_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4449 if ( eel_not_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4452 if ( eel_ignore.getAllDomainIds().size() != 8 ) {
4455 if ( !eel_ignore.getAllDomainIds().contains( a.getDomainId() ) ) {
4458 if ( !eel_ignore.getAllDomainIds().contains( b.getDomainId() ) ) {
4461 if ( !eel_ignore.getAllDomainIds().contains( c.getDomainId() ) ) {
4464 if ( !eel_ignore.getAllDomainIds().contains( d.getDomainId() ) ) {
4467 if ( !eel_ignore.getAllDomainIds().contains( e.getDomainId() ) ) {
4470 if ( !eel_ignore.getAllDomainIds().contains( f.getDomainId() ) ) {
4473 if ( !eel_ignore.getAllDomainIds().contains( g.getDomainId() ) ) {
4476 if ( !eel_ignore.getAllDomainIds().contains( h.getDomainId() ) ) {
4479 if ( eel_ignore.getAllDomainIds().contains( x.getDomainId() ) ) {
4482 final SortedSet<BinaryDomainCombination> bc0 = eel_not_ignore.toBinaryDomainCombinations();
4483 if ( bc0.size() != 15 ) {
4486 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4489 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4492 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4495 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4498 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4501 if ( !bc0.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4504 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4507 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4510 if ( !bc0.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4513 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4516 if ( !bc0.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
4519 if ( !bc0.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
4522 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
4525 if ( !bc0.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
4528 if ( !bc0.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
4531 if ( !bc0.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
4534 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
4537 if ( bc0.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
4540 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "h" ) ) ) {
4543 if ( bc0.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
4546 final SortedSet<BinaryDomainCombination> bc1 = eel_ignore.toBinaryDomainCombinations();
4547 if ( bc1.size() != 12 ) {
4550 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "a" ) ) ) {
4553 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "b" ) ) ) {
4556 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "a" ) ) ) {
4559 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "c" ) ) ) {
4562 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "d" ) ) ) {
4565 if ( !bc1.contains( new BasicBinaryDomainCombination( "a", "e" ) ) ) {
4568 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "c" ) ) ) {
4571 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "d" ) ) ) {
4574 if ( !bc1.contains( new BasicBinaryDomainCombination( "b", "e" ) ) ) {
4577 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "d" ) ) ) {
4580 if ( !bc1.contains( new BasicBinaryDomainCombination( "c", "e" ) ) ) {
4583 if ( !bc1.contains( new BasicBinaryDomainCombination( "d", "e" ) ) ) {
4586 if ( !bc1.contains( new BasicBinaryDomainCombination( "e", "f" ) ) ) {
4589 if ( !bc1.contains( new BasicBinaryDomainCombination( "g", "h" ) ) ) {
4592 if ( bc1.contains( new BasicBinaryDomainCombination( "e", "e" ) ) ) {
4595 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "f" ) ) ) {
4598 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "a" ) ) ) {
4601 if ( bc1.contains( new BasicBinaryDomainCombination( "f", "b" ) ) ) {
4604 if ( bc1.contains( new BasicBinaryDomainCombination( "a", "g" ) ) ) {
4607 if ( bc1.contains( new BasicBinaryDomainCombination( "b", "g" ) ) ) {
4611 catch ( final Exception e ) {
4612 e.printStackTrace( System.out );
4618 private static boolean testHmmPfamOutputParser( final File test_dir ) {
4620 final HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir
4621 + ForesterUtil.getFileSeparator() + "hmmpfam_output" ), "human", "ls" );
4622 parser.setEValueMaximum( 0.2 );
4623 parser.setIgnoreDufs( true );
4624 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4625 List<?> domain_collections = null;
4626 domain_collections = parser.parse();
4627 if ( parser.getDomainsEncountered() != 4 ) {
4630 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
4633 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
4636 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
4639 if ( parser.getDomainsStored() != 3 ) {
4642 if ( domain_collections.size() != 1 ) {
4645 final Protein pdc = ( Protein ) domain_collections.get( 0 );
4646 if ( !pdc.getProteinId().equals( new ProteinId( "ENSP00000285681" ) ) ) {
4649 if ( !pdc.getSpecies().getSpeciesId().equals( "human" ) ) {
4652 if ( pdc.getNumberOfProteinDomains() != 3 ) {
4655 if ( !pdc.getAccession().equals( "acc_ENSP00000285681" ) ) {
4660 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
4663 final List<Domain> uba = pdc.getProteinDomains( new DomainId( "UBA" ) );
4664 final List<Domain> uim = pdc.getProteinDomains( new DomainId( "UIM" ) );
4665 final List<Domain> uch = pdc.getProteinDomains( new DomainId( "UCH" ) );
4666 if ( uba.size() != 1 ) {
4669 if ( uim.size() != 2 ) {
4672 if ( uch.size() != 0 ) {
4675 final BasicDomain uim_domain = ( BasicDomain ) uim.get( 1 );
4676 if ( !uim_domain.getDomainId().equals( new DomainId( "UIM" ) ) ) {
4679 if ( uim_domain.getTotalCount() != 2 ) {
4682 final BasicDomain uba_domain = ( BasicDomain ) uba.get( 0 );
4683 if ( !uba_domain.getDomainId().equals( new DomainId( "UBA" ) ) ) {
4686 if ( uba_domain.getNumber() != 1 ) {
4689 if ( uba_domain.getTotalCount() != 1 ) {
4692 if ( uba_domain.getFrom() != 16 ) {
4695 if ( uba_domain.getTo() != 57 ) {
4698 if ( !Test.isEqual( uba_domain.getPerSequenceEvalue(), 0.00084 ) ) {
4701 if ( !Test.isEqual( uba_domain.getPerSequenceScore(), 23.2 ) ) {
4704 final HmmPfamOutputParser parser2 = new HmmPfamOutputParser( new File( test_dir
4705 + ForesterUtil.getFileSeparator() + "hmmpfam_output_short" ), "human", "ls" );
4706 parser2.setEValueMaximum( 0.2 );
4707 parser2.setIgnoreDufs( true );
4708 parser2.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4709 List<Protein> domain_collections2 = null;
4710 domain_collections2 = parser2.parse();
4711 if ( parser2.getDomainsEncountered() != 4 ) {
4714 if ( parser.getDomainsIgnoredDueToDuf() != 0 ) {
4717 if ( parser.getDomainsIgnoredDueToEval() != 1 ) {
4720 if ( parser.getDomainsIgnoredDueToOverlap() != 0 ) {
4723 if ( parser2.getDomainsStored() != 3 ) {
4726 if ( domain_collections2.size() != 1 ) {
4729 final Protein pdc2 = domain_collections2.get( 0 );
4730 if ( !pdc2.getProteinId().getId().equals( "ENSP00000285681" ) ) {
4733 if ( !pdc2.getSpecies().getSpeciesId().equals( "human" ) ) {
4736 if ( !pdc2.getName().equals( "" ) ) {
4739 if ( !pdc2.getAccession().equals( "223" ) ) {
4744 .equals( "pep:known chromosome:NCBI36:21:16024215:16174248:1 gene:ENSG00000155313 transcript:ENST00000285681" ) ) {
4747 if ( pdc2.getNumberOfProteinDomains() != 3 ) {
4750 final List<Domain> uba2 = pdc2.getProteinDomains( new DomainId( "UBA" ) );
4751 final List<Domain> uim2 = pdc2.getProteinDomains( new DomainId( "UIM" ) );
4752 final List<Domain> uch2 = pdc2.getProteinDomains( new DomainId( "UCH" ) );
4753 if ( uba2.size() != 1 ) {
4756 if ( uim2.size() != 2 ) {
4759 if ( uch2.size() != 0 ) {
4762 final BasicDomain uim_domain2 = ( BasicDomain ) uim2.get( 1 );
4763 if ( !uim_domain2.getDomainId().getId().equals( "UIM" ) ) {
4766 if ( uim_domain2.getTotalCount() != 2 ) {
4769 final BasicDomain uba_domain2 = ( BasicDomain ) uba2.get( 0 );
4770 if ( !uba_domain2.getDomainId().getId().equals( "UBA" ) ) {
4773 if ( uba_domain2.getNumber() != 1 ) {
4776 if ( uba_domain2.getTotalCount() != 1 ) {
4779 if ( uba_domain2.getFrom() != 16 ) {
4782 if ( uba_domain2.getTo() != 57 ) {
4785 if ( !Test.isEqual( uba_domain2.getPerSequenceEvalue(), 0.00084 ) ) {
4789 catch ( final Exception e ) {
4790 e.printStackTrace( System.out );
4796 private static boolean testHmmPfamOutputParserWithFilter( final File test_dir ) {
4798 HmmPfamOutputParser parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator()
4799 + "hmmpfam_output3" ), "human", "ls" );
4800 parser.setEValueMaximum( 0.2 );
4801 parser.setIgnoreDufs( true );
4802 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4803 List<Protein> proteins = null;
4804 proteins = parser.parse();
4805 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
4808 if ( proteins.size() != 4 ) {
4812 Set<DomainId> filter = new TreeSet<DomainId>();
4813 filter.add( new DomainId( "beauty" ) );
4814 filter.add( new DomainId( "strange" ) );
4815 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
4819 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
4820 parser.setEValueMaximum( 0.2 );
4821 parser.setIgnoreDufs( true );
4822 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4824 proteins = parser.parse();
4825 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
4828 if ( proteins.size() != 4 ) {
4832 filter = new TreeSet<DomainId>();
4833 filter.add( new DomainId( "beauty" ) );
4834 filter.add( new DomainId( "strange" ) );
4835 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
4839 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
4840 parser.setEValueMaximum( 0.2 );
4841 parser.setIgnoreDufs( true );
4842 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4844 proteins = parser.parse();
4845 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
4848 if ( proteins.size() != 0 ) {
4852 filter = new TreeSet<DomainId>();
4853 filter.add( new DomainId( "UIM" ) );
4854 filter.add( new DomainId( "A" ) );
4855 filter.add( new DomainId( "C" ) );
4856 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
4860 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
4861 parser.setEValueMaximum( 0.2 );
4862 parser.setIgnoreDufs( true );
4863 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4865 proteins = parser.parse();
4866 if ( parser.getProteinsIgnoredDueToFilter() != 0 ) {
4869 if ( proteins.size() != 4 ) {
4873 filter = new TreeSet<DomainId>();
4874 filter.add( new DomainId( "UIM" ) );
4875 filter.add( new DomainId( "A" ) );
4876 filter.add( new DomainId( "C" ) );
4877 filter.add( new DomainId( "X" ) );
4878 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
4882 HmmPfamOutputParser.FilterType.NEGATIVE_DOMAIN );
4883 parser.setEValueMaximum( 0.2 );
4884 parser.setIgnoreDufs( true );
4885 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4887 proteins = parser.parse();
4888 if ( parser.getDomainsIgnoredDueToNegativeDomainFilter() != 7 ) {
4891 if ( proteins.size() != 3 ) {
4895 filter = new TreeSet<DomainId>();
4896 filter.add( new DomainId( "UIM" ) );
4897 filter.add( new DomainId( "A" ) );
4898 filter.add( new DomainId( "C" ) );
4899 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
4903 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
4904 parser.setEValueMaximum( 0.2 );
4905 parser.setIgnoreDufs( true );
4906 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4908 proteins = parser.parse();
4909 if ( parser.getProteinsIgnoredDueToFilter() != 4 ) {
4912 if ( proteins.size() != 0 ) {
4916 filter = new TreeSet<DomainId>();
4917 filter.add( new DomainId( "UIM" ) );
4918 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
4922 HmmPfamOutputParser.FilterType.NEGATIVE_PROTEIN );
4923 parser.setEValueMaximum( 0.2 );
4924 parser.setIgnoreDufs( true );
4925 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4927 proteins = parser.parse();
4928 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
4931 if ( parser.getProteinsStored() != 3 ) {
4934 if ( proteins.size() != 3 ) {
4938 filter = new TreeSet<DomainId>();
4939 filter.add( new DomainId( "UIM" ) );
4940 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
4944 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
4945 parser.setEValueMaximum( 0.2 );
4946 parser.setIgnoreDufs( true );
4947 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4949 proteins = parser.parse();
4950 if ( parser.getProteinsIgnoredDueToFilter() != 3 ) {
4953 if ( parser.getProteinsStored() != 1 ) {
4956 if ( proteins.size() != 1 ) {
4960 filter = new TreeSet<DomainId>();
4961 filter.add( new DomainId( "A" ) );
4962 filter.add( new DomainId( "C" ) );
4963 parser = new HmmPfamOutputParser( new File( test_dir + ForesterUtil.getFileSeparator() + "hmmpfam_output3" ),
4967 HmmPfamOutputParser.FilterType.POSITIVE_PROTEIN );
4968 parser.setEValueMaximum( 0.2 );
4969 parser.setIgnoreDufs( true );
4970 parser.setReturnType( HmmPfamOutputParser.ReturnType.UNORDERED_PROTEIN_DOMAIN_COLLECTION_PER_PROTEIN );
4972 proteins = parser.parse();
4973 if ( parser.getDomainsEncountered() != 11 ) {
4976 if ( parser.getProteinsEncountered() != 4 ) {
4979 if ( parser.getProteinsIgnoredDueToFilter() != 1 ) {
4982 if ( parser.getProteinsStored() != 3 ) {
4985 if ( proteins.size() != 3 ) {
4989 catch ( final Exception e ) {
4990 e.printStackTrace( System.out );
4996 private static boolean testOverlapRemoval() {
4998 final Domain d0 = new BasicDomain( "d0", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.1, 1 );
4999 final Domain d1 = new BasicDomain( "d1", ( short ) 7, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5000 final Domain d2 = new BasicDomain( "d2", ( short ) 0, ( short ) 20, ( short ) 1, ( short ) 1, 0.1, 1 );
5001 final Domain d3 = new BasicDomain( "d3", ( short ) 9, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5002 final Domain d4 = new BasicDomain( "d4", ( short ) 7, ( short ) 8, ( short ) 1, ( short ) 1, 0.1, 1 );
5003 final List<Boolean> covered = new ArrayList<Boolean>();
5004 covered.add( true ); // 0
5005 covered.add( false ); // 1
5006 covered.add( true ); // 2
5007 covered.add( false ); // 3
5008 covered.add( true ); // 4
5009 covered.add( true ); // 5
5010 covered.add( false ); // 6
5011 covered.add( true ); // 7
5012 covered.add( true ); // 8
5013 if ( SurfacingUtil.calculateOverlap( d0, covered ) != 3 ) {
5016 if ( SurfacingUtil.calculateOverlap( d1, covered ) != 2 ) {
5019 if ( SurfacingUtil.calculateOverlap( d2, covered ) != 6 ) {
5022 if ( SurfacingUtil.calculateOverlap( d3, covered ) != 0 ) {
5025 if ( SurfacingUtil.calculateOverlap( d4, covered ) != 2 ) {
5028 final Domain a = new BasicDomain( "a", ( short ) 2, ( short ) 5, ( short ) 1, ( short ) 1, 0.01, 1 );
5029 final Domain b = new BasicDomain( "b", ( short ) 2, ( short ) 10, ( short ) 1, ( short ) 1, 0.1, 1 );
5030 final Protein ab = new BasicProtein( "ab", "varanus", 0 );
5031 ab.addProteinDomain( a );
5032 ab.addProteinDomain( b );
5033 final Protein ab_s0 = SurfacingUtil.removeOverlappingDomains( 3, false, ab );
5034 if ( ab.getNumberOfProteinDomains() != 2 ) {
5037 if ( ab_s0.getNumberOfProteinDomains() != 1 ) {
5040 if ( !ab_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "a" ) ) {
5043 final Protein ab_s1 = SurfacingUtil.removeOverlappingDomains( 4, false, ab );
5044 if ( ab.getNumberOfProteinDomains() != 2 ) {
5047 if ( ab_s1.getNumberOfProteinDomains() != 2 ) {
5050 final Domain c = new BasicDomain( "c", ( short ) 20000, ( short ) 20500, ( short ) 1, ( short ) 1, 10, 1 );
5051 final Domain d = new BasicDomain( "d",
5058 final Domain e = new BasicDomain( "e", ( short ) 5000, ( short ) 5500, ( short ) 1, ( short ) 1, 0.0001, 1 );
5059 final Protein cde = new BasicProtein( "cde", "varanus", 0 );
5060 cde.addProteinDomain( c );
5061 cde.addProteinDomain( d );
5062 cde.addProteinDomain( e );
5063 final Protein cde_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, cde );
5064 if ( cde.getNumberOfProteinDomains() != 3 ) {
5067 if ( cde_s0.getNumberOfProteinDomains() != 3 ) {
5070 final Domain f = new BasicDomain( "f", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5071 final Domain g = new BasicDomain( "g", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5072 final Domain h = new BasicDomain( "h", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5073 final Domain i = new BasicDomain( "i", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.5, 1 );
5074 final Domain i2 = new BasicDomain( "i", ( short ) 5, ( short ) 30, ( short ) 1, ( short ) 1, 0.5, 10 );
5075 final Protein fghi = new BasicProtein( "fghi", "varanus", 0 );
5076 fghi.addProteinDomain( f );
5077 fghi.addProteinDomain( g );
5078 fghi.addProteinDomain( h );
5079 fghi.addProteinDomain( i );
5080 fghi.addProteinDomain( i );
5081 fghi.addProteinDomain( i );
5082 fghi.addProteinDomain( i2 );
5083 final Protein fghi_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, fghi );
5084 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5087 if ( fghi_s0.getNumberOfProteinDomains() != 1 ) {
5090 if ( !fghi_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "h" ) ) {
5093 final Protein fghi_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, fghi );
5094 if ( fghi.getNumberOfProteinDomains() != 7 ) {
5097 if ( fghi_s1.getNumberOfProteinDomains() != 7 ) {
5100 final Domain j = new BasicDomain( "j", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 10, 1 );
5101 final Domain k = new BasicDomain( "k", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.01, 1 );
5102 final Domain l = new BasicDomain( "l", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 1, 0.0001, 1 );
5103 final Domain m = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 1, ( short ) 4, 0.5, 1 );
5104 final Domain m0 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 2, ( short ) 4, 0.5, 1 );
5105 final Domain m1 = new BasicDomain( "m", ( short ) 10, ( short ) 20, ( short ) 3, ( short ) 4, 0.5, 1 );
5106 final Domain m2 = new BasicDomain( "m", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5107 final Protein jklm = new BasicProtein( "jklm", "varanus", 0 );
5108 jklm.addProteinDomain( j );
5109 jklm.addProteinDomain( k );
5110 jklm.addProteinDomain( l );
5111 jklm.addProteinDomain( m );
5112 jklm.addProteinDomain( m0 );
5113 jklm.addProteinDomain( m1 );
5114 jklm.addProteinDomain( m2 );
5115 final Protein jklm_s0 = SurfacingUtil.removeOverlappingDomains( 10, false, jklm );
5116 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5119 if ( jklm_s0.getNumberOfProteinDomains() != 1 ) {
5122 if ( !jklm_s0.getProteinDomain( 0 ).getDomainId().getId().equals( "l" ) ) {
5125 final Protein jklm_s1 = SurfacingUtil.removeOverlappingDomains( 11, false, jklm );
5126 if ( jklm.getNumberOfProteinDomains() != 7 ) {
5129 if ( jklm_s1.getNumberOfProteinDomains() != 7 ) {
5132 final Domain only = new BasicDomain( "only", ( short ) 5, ( short ) 30, ( short ) 4, ( short ) 4, 0.5, 10 );
5133 final Protein od = new BasicProtein( "od", "varanus", 0 );
5134 od.addProteinDomain( only );
5135 final Protein od_s0 = SurfacingUtil.removeOverlappingDomains( 0, false, od );
5136 if ( od.getNumberOfProteinDomains() != 1 ) {
5139 if ( od_s0.getNumberOfProteinDomains() != 1 ) {
5143 catch ( final Exception e ) {
5144 e.printStackTrace( System.out );
5150 private static boolean testParsimony() {
5152 final BinaryStates X = BinaryStates.PRESENT;
5153 final BinaryStates O = BinaryStates.ABSENT;
5154 final GainLossStates G = GainLossStates.GAIN;
5155 final GainLossStates L = GainLossStates.LOSS;
5156 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5157 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5158 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5159 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5160 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5161 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5162 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5163 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5164 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5165 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5166 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5167 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5168 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5169 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5170 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5171 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5172 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5173 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5174 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5175 // 1 a-a a-b a-c e-f-g-h l-m
5176 // 2 a-b a-c e-f-g-i n-o
5177 // 3 a-b a-d e-f-g-j p-q
5179 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5180 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5181 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5183 // 1 a b c e f g h l m
5184 // 2 a b c e f g i n o
5185 // 3 a b d e f g j p q
5187 final Protein aa1 = new BasicProtein( "aa1", "one", 0 );
5188 aa1.addProteinDomain( a );
5189 aa1.addProteinDomain( a );
5190 final Protein ab1 = new BasicProtein( "ab1", "one", 0 );
5191 ab1.addProteinDomain( a );
5192 ab1.addProteinDomain( b );
5193 final Protein ac1 = new BasicProtein( "ac1", "one", 0 );
5194 ac1.addProteinDomain( a );
5195 ac1.addProteinDomain( c );
5196 final Protein efgh1 = new BasicProtein( "efgh1", "one", 0 );
5197 efgh1.addProteinDomain( e );
5198 efgh1.addProteinDomain( f );
5199 efgh1.addProteinDomain( g );
5200 efgh1.addProteinDomain( h );
5201 final Protein lm1 = new BasicProtein( "lm1", "one", 0 );
5202 lm1.addProteinDomain( l );
5203 lm1.addProteinDomain( m );
5204 final Protein ab2 = new BasicProtein( "ab2", "two", 0 );
5205 ab2.addProteinDomain( a );
5206 ab2.addProteinDomain( b );
5207 final Protein ac2 = new BasicProtein( "ac2", "two", 0 );
5208 ac2.addProteinDomain( a );
5209 ac2.addProteinDomain( c );
5210 final Protein efgi2 = new BasicProtein( "efgi2", "two", 0 );
5211 efgi2.addProteinDomain( e );
5212 efgi2.addProteinDomain( f );
5213 efgi2.addProteinDomain( g );
5214 efgi2.addProteinDomain( i );
5215 final Protein no2 = new BasicProtein( "no2", "two", 0 );
5216 no2.addProteinDomain( n );
5217 no2.addProteinDomain( o );
5218 final Protein ab3 = new BasicProtein( "ab3", "three", 0 );
5219 ab3.addProteinDomain( a );
5220 ab3.addProteinDomain( b );
5221 final Protein ad3 = new BasicProtein( "ad3", "three", 0 );
5222 ad3.addProteinDomain( a );
5223 ad3.addProteinDomain( d );
5224 final Protein efgj3 = new BasicProtein( "efgj3", "three", 0 );
5225 efgj3.addProteinDomain( e );
5226 efgj3.addProteinDomain( f );
5227 efgj3.addProteinDomain( g );
5228 efgj3.addProteinDomain( j );
5229 final Protein pq3 = new BasicProtein( "pq3", "three", 0 );
5230 pq3.addProteinDomain( p );
5231 pq3.addProteinDomain( q );
5232 final Protein ab4 = new BasicProtein( "ab4", "four", 0 );
5233 ab4.addProteinDomain( a );
5234 ab4.addProteinDomain( b );
5235 final Protein ad4 = new BasicProtein( "ad4", "four", 0 );
5236 ad4.addProteinDomain( a );
5237 ad4.addProteinDomain( d );
5238 final Protein pr4 = new BasicProtein( "pr4", "four", 0 );
5239 pr4.addProteinDomain( p );
5240 pr4.addProteinDomain( r );
5241 final List<Protein> one_list = new ArrayList<Protein>();
5242 one_list.add( aa1 );
5243 one_list.add( ab1 );
5244 one_list.add( ac1 );
5245 one_list.add( efgh1 );
5246 one_list.add( lm1 );
5247 final List<Protein> two_list = new ArrayList<Protein>();
5248 two_list.add( ab2 );
5249 two_list.add( ac2 );
5250 two_list.add( efgi2 );
5251 two_list.add( no2 );
5252 final List<Protein> three_list = new ArrayList<Protein>();
5253 three_list.add( ab3 );
5254 three_list.add( ad3 );
5255 three_list.add( efgj3 );
5256 three_list.add( pq3 );
5257 final List<Protein> four_list = new ArrayList<Protein>();
5258 four_list.add( ab4 );
5259 four_list.add( ad4 );
5260 four_list.add( pr4 );
5261 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5262 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5263 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5264 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5265 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5266 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5267 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5268 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5269 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5270 gwcd_list.add( one );
5271 gwcd_list.add( two );
5272 gwcd_list.add( three );
5273 gwcd_list.add( four );
5274 final CharacterStateMatrix<BinaryStates> matrix_d = DomainParsimonyCalculator
5275 .createMatrixOfDomainPresenceOrAbsence( gwcd_list );
5276 final CharacterStateMatrix<BinaryStates> matrix_bc = DomainParsimonyCalculator
5277 .createMatrixOfBinaryDomainCombinationPresenceOrAbsence( gwcd_list );
5278 // 1 a b c e f g h l m
5279 // 2 a b c e f g i n o
5280 // 3 a b d e f g j p q
5282 if ( matrix_d.getState( 0, 0 ) != X ) {
5285 if ( matrix_d.getState( 0, 1 ) != X ) {
5288 if ( matrix_d.getState( 0, 2 ) != X ) {
5291 if ( matrix_d.getState( 0, 3 ) != O ) {
5294 if ( matrix_d.getState( 0, 4 ) != X ) {
5297 if ( matrix_d.getState( 0, 5 ) != X ) {
5300 if ( matrix_d.getState( 0, 6 ) != X ) {
5303 if ( matrix_d.getState( 0, 7 ) != X ) {
5306 if ( matrix_d.getState( 0, 8 ) != O ) {
5309 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5310 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5311 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5313 if ( matrix_bc.getState( 0, 0 ) != X ) {
5316 if ( matrix_bc.getState( 0, 1 ) != X ) {
5319 if ( matrix_bc.getState( 0, 2 ) != X ) {
5322 if ( matrix_bc.getState( 0, 3 ) != O ) {
5325 if ( matrix_bc.getState( 0, 4 ) != X ) {
5328 if ( matrix_bc.getState( 1, 0 ) != O ) {
5331 if ( matrix_bc.getState( 1, 1 ) != X ) {
5334 if ( matrix_bc.getState( 1, 2 ) != X ) {
5337 if ( matrix_bc.getState( 1, 3 ) != O ) {
5340 if ( matrix_bc.getState( 1, 4 ) != X ) {
5343 if ( matrix_bc.getState( 2, 0 ) != O ) {
5346 if ( matrix_bc.getState( 2, 1 ) != X ) {
5349 if ( matrix_bc.getState( 2, 2 ) != O ) {
5352 if ( matrix_bc.getState( 2, 3 ) != X ) {
5355 if ( matrix_bc.getState( 2, 4 ) != X ) {
5358 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
5359 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
5360 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
5361 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list );
5362 dp0.executeDolloParsimonyOnDomainPresence();
5363 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
5364 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
5365 dp0.executeDolloParsimonyOnBinaryDomainCombintionPresence();
5366 final CharacterStateMatrix<GainLossStates> gl_matrix_bc = dp0.getGainLossMatrix();
5367 final CharacterStateMatrix<BinaryStates> is_matrix_bc = dp0.getInternalStatesMatrix();
5368 if ( is_matrix_d.getState( "root", "A" ) != X ) {
5371 if ( is_matrix_d.getState( "root", "B" ) != X ) {
5374 if ( is_matrix_d.getState( "root", "C" ) != O ) {
5377 if ( is_matrix_d.getState( "root", "D" ) != O ) {
5380 if ( is_matrix_d.getState( "root", "E" ) != X ) {
5383 if ( is_matrix_bc.getState( "root", "A=A" ) != O ) {
5386 if ( is_matrix_bc.getState( "root", "A=B" ) != X ) {
5389 if ( is_matrix_bc.getState( "root", "A=C" ) != O ) {
5392 if ( is_matrix_bc.getState( "root", "A=D" ) != O ) {
5395 if ( is_matrix_bc.getState( "root", "G=H" ) != O ) {
5398 if ( is_matrix_bc.getState( "1-2", "G=H" ) != O ) {
5401 if ( is_matrix_bc.getState( "root", "E=F" ) != X ) {
5404 if ( gl_matrix_bc.getState( "root", "E=F" ) != P ) {
5407 if ( gl_matrix_bc.getState( "root", "A=A" ) != A ) {
5410 if ( gl_matrix_bc.getState( "one", "A=A" ) != G ) {
5413 if ( gl_matrix_bc.getState( "root", "A=B" ) != P ) {
5416 if ( gl_matrix_bc.getState( "3-4", "A=D" ) != G ) {
5419 if ( gl_matrix_bc.getState( "four", "E=F" ) != L ) {
5422 if ( gl_matrix_d.getState( "3-4", "P" ) != G ) {
5426 catch ( final Exception e ) {
5427 e.printStackTrace( System.out );
5433 private static boolean testParsimonyOnSecondaryFeatures() {
5435 final BinaryStates X = BinaryStates.PRESENT;
5436 final BinaryStates O = BinaryStates.ABSENT;
5437 final GainLossStates G = GainLossStates.GAIN;
5438 final GainLossStates L = GainLossStates.LOSS;
5439 final GainLossStates A = GainLossStates.UNCHANGED_ABSENT;
5440 final GainLossStates P = GainLossStates.UNCHANGED_PRESENT;
5441 final Domain a = new BasicDomain( "A", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5442 final Domain b = new BasicDomain( "B", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5443 final Domain c = new BasicDomain( "C", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5444 final Domain d = new BasicDomain( "D", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5445 final Domain e = new BasicDomain( "E", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5446 final Domain f = new BasicDomain( "F", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5447 final Domain g = new BasicDomain( "G", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5448 final Domain h = new BasicDomain( "H", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5449 final Domain i = new BasicDomain( "I", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5450 final Domain j = new BasicDomain( "J", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5451 final Domain l = new BasicDomain( "L", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5452 final Domain m = new BasicDomain( "M", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5453 final Domain n = new BasicDomain( "N", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5454 final Domain o = new BasicDomain( "O", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5455 final Domain p = new BasicDomain( "P", 1, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5456 final Domain q = new BasicDomain( "Q", 2, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5457 final Domain r = new BasicDomain( "R", 3, 25, ( short ) 1, ( short ) 4, 0.1, -12 );
5458 // 1 a-a a-b a-c e-f-g-h l-m
5459 // 2 a-b a-c e-f-g-i n-o
5460 // 3 a-b a-d e-f-g-j p-q
5462 // 1 a-a a-b a-c e-f e-g e-h f-g f-h g-h l-m
5463 // 2 a-b a-c e-f e-g e-i f-g f-i g-i n-o
5464 // 3 a-b a-d e-f e-g e-j f-g f-j g-j p-q
5466 // 1 a b c e f g h l m
5467 // 2 a b c e f g i n o
5468 // 3 a b d e f g j p q
5470 final Protein aa1 = new BasicProtein( "aa1", "one", 0 );
5471 aa1.addProteinDomain( a );
5472 aa1.addProteinDomain( a );
5473 final Protein ab1 = new BasicProtein( "ab1", "one", 0 );
5474 ab1.addProteinDomain( a );
5475 ab1.addProteinDomain( b );
5476 final Protein ac1 = new BasicProtein( "ac1", "one", 0 );
5477 ac1.addProteinDomain( a );
5478 ac1.addProteinDomain( c );
5479 final Protein efgh1 = new BasicProtein( "efgh1", "one", 0 );
5480 efgh1.addProteinDomain( e );
5481 efgh1.addProteinDomain( f );
5482 efgh1.addProteinDomain( g );
5483 efgh1.addProteinDomain( h );
5484 final Protein lm1 = new BasicProtein( "lm1", "one", 0 );
5485 lm1.addProteinDomain( l );
5486 lm1.addProteinDomain( m );
5487 final Protein ab2 = new BasicProtein( "ab2", "two", 0 );
5488 ab2.addProteinDomain( a );
5489 ab2.addProteinDomain( b );
5490 final Protein ac2 = new BasicProtein( "ac2", "two", 0 );
5491 ac2.addProteinDomain( a );
5492 ac2.addProteinDomain( c );
5493 final Protein efgi2 = new BasicProtein( "efgi2", "two", 0 );
5494 efgi2.addProteinDomain( e );
5495 efgi2.addProteinDomain( f );
5496 efgi2.addProteinDomain( g );
5497 efgi2.addProteinDomain( i );
5498 final Protein no2 = new BasicProtein( "no2", "two", 0 );
5499 no2.addProteinDomain( n );
5500 no2.addProteinDomain( o );
5501 final Protein ab3 = new BasicProtein( "ab3", "three", 0 );
5502 ab3.addProteinDomain( a );
5503 ab3.addProteinDomain( b );
5504 final Protein ad3 = new BasicProtein( "ad3", "three", 0 );
5505 ad3.addProteinDomain( a );
5506 ad3.addProteinDomain( d );
5507 final Protein efgj3 = new BasicProtein( "efgj3", "three", 0 );
5508 efgj3.addProteinDomain( e );
5509 efgj3.addProteinDomain( f );
5510 efgj3.addProteinDomain( g );
5511 efgj3.addProteinDomain( j );
5512 final Protein pq3 = new BasicProtein( "pq3", "three", 0 );
5513 pq3.addProteinDomain( p );
5514 pq3.addProteinDomain( q );
5515 final Protein ab4 = new BasicProtein( "ab4", "four", 0 );
5516 ab4.addProteinDomain( a );
5517 ab4.addProteinDomain( b );
5518 final Protein ad4 = new BasicProtein( "ad4", "four", 0 );
5519 ad4.addProteinDomain( a );
5520 ad4.addProteinDomain( d );
5521 final Protein pr4 = new BasicProtein( "pr4", "four", 0 );
5522 pr4.addProteinDomain( p );
5523 pr4.addProteinDomain( r );
5524 final List<Protein> one_list = new ArrayList<Protein>();
5525 one_list.add( aa1 );
5526 one_list.add( ab1 );
5527 one_list.add( ac1 );
5528 one_list.add( efgh1 );
5529 one_list.add( lm1 );
5530 final List<Protein> two_list = new ArrayList<Protein>();
5531 two_list.add( ab2 );
5532 two_list.add( ac2 );
5533 two_list.add( efgi2 );
5534 two_list.add( no2 );
5535 final List<Protein> three_list = new ArrayList<Protein>();
5536 three_list.add( ab3 );
5537 three_list.add( ad3 );
5538 three_list.add( efgj3 );
5539 three_list.add( pq3 );
5540 final List<Protein> four_list = new ArrayList<Protein>();
5541 four_list.add( ab4 );
5542 four_list.add( ad4 );
5543 four_list.add( pr4 );
5544 final GenomeWideCombinableDomains one = BasicGenomeWideCombinableDomains
5545 .createInstance( one_list, false, new BasicSpecies( "one" ) );
5546 final GenomeWideCombinableDomains two = BasicGenomeWideCombinableDomains
5547 .createInstance( two_list, false, new BasicSpecies( "two" ) );
5548 final GenomeWideCombinableDomains three = BasicGenomeWideCombinableDomains
5549 .createInstance( three_list, false, new BasicSpecies( "three" ) );
5550 final GenomeWideCombinableDomains four = BasicGenomeWideCombinableDomains
5551 .createInstance( four_list, false, new BasicSpecies( "four" ) );
5552 final List<GenomeWideCombinableDomains> gwcd_list = new ArrayList<GenomeWideCombinableDomains>();
5553 gwcd_list.add( one );
5554 gwcd_list.add( two );
5555 gwcd_list.add( three );
5556 gwcd_list.add( four );
5557 final Map<DomainId, Set<String>> map_same = new HashMap<DomainId, Set<String>>();
5558 final HashSet<String> a_s = new HashSet<String>();
5560 final HashSet<String> b_s = new HashSet<String>();
5562 final HashSet<String> c_s = new HashSet<String>();
5564 final HashSet<String> d_s = new HashSet<String>();
5566 final HashSet<String> e_s = new HashSet<String>();
5568 final HashSet<String> f_s = new HashSet<String>();
5570 final HashSet<String> g_s = new HashSet<String>();
5572 final HashSet<String> h_s = new HashSet<String>();
5574 final HashSet<String> i_s = new HashSet<String>();
5576 final HashSet<String> j_s = new HashSet<String>();
5578 final HashSet<String> l_s = new HashSet<String>();
5580 final HashSet<String> m_s = new HashSet<String>();
5582 final HashSet<String> n_s = new HashSet<String>();
5584 final HashSet<String> o_s = new HashSet<String>();
5586 final HashSet<String> p_s = new HashSet<String>();
5588 final HashSet<String> q_s = new HashSet<String>();
5590 final HashSet<String> r_s = new HashSet<String>();
5592 map_same.put( a.getDomainId(), a_s );
5593 map_same.put( b.getDomainId(), b_s );
5594 map_same.put( c.getDomainId(), c_s );
5595 map_same.put( d.getDomainId(), d_s );
5596 map_same.put( e.getDomainId(), e_s );
5597 map_same.put( f.getDomainId(), f_s );
5598 map_same.put( g.getDomainId(), g_s );
5599 map_same.put( h.getDomainId(), h_s );
5600 map_same.put( i.getDomainId(), i_s );
5601 map_same.put( j.getDomainId(), j_s );
5602 map_same.put( l.getDomainId(), l_s );
5603 map_same.put( m.getDomainId(), m_s );
5604 map_same.put( n.getDomainId(), n_s );
5605 map_same.put( o.getDomainId(), o_s );
5606 map_same.put( p.getDomainId(), p_s );
5607 map_same.put( q.getDomainId(), q_s );
5608 map_same.put( r.getDomainId(), r_s );
5609 final CharacterStateMatrix<BinaryStates> matrix_s = DomainParsimonyCalculator
5610 .createMatrixOfSecondaryFeaturePresenceOrAbsence( gwcd_list, map_same, null );
5611 // 1 a b c e f g h l m
5612 // 2 a b c e f g i n o
5613 // 3 a b d e f g j p q
5615 if ( matrix_s.getState( 0, 0 ) != X ) {
5618 if ( matrix_s.getState( 0, 1 ) != X ) {
5621 if ( matrix_s.getState( 0, 2 ) != X ) {
5624 if ( matrix_s.getState( 0, 3 ) != O ) {
5627 if ( matrix_s.getState( 0, 4 ) != X ) {
5630 if ( matrix_s.getState( 0, 5 ) != X ) {
5633 if ( matrix_s.getState( 0, 6 ) != X ) {
5636 if ( matrix_s.getState( 0, 7 ) != X ) {
5639 if ( matrix_s.getState( 0, 8 ) != O ) {
5642 final PhylogenyFactory factory0 = ParserBasedPhylogenyFactory.getInstance();
5643 final String p0_str = "((one,two)1-2,(three,four)3-4)root";
5644 final Phylogeny p0 = factory0.create( p0_str, new NHXParser() )[ 0 ];
5645 final DomainParsimonyCalculator dp0 = DomainParsimonyCalculator.createInstance( p0, gwcd_list, map_same );
5646 dp0.executeDolloParsimonyOnSecondaryFeatures( null );
5647 final CharacterStateMatrix<GainLossStates> gl_matrix_d = dp0.getGainLossMatrix();
5648 final CharacterStateMatrix<BinaryStates> is_matrix_d = dp0.getInternalStatesMatrix();
5649 if ( is_matrix_d.getState( "root", "AAA" ) != X ) {
5652 if ( is_matrix_d.getState( "root", "BBB" ) != X ) {
5655 if ( is_matrix_d.getState( "root", "CCC" ) != O ) {
5658 if ( is_matrix_d.getState( "root", "DDD" ) != O ) {
5661 if ( is_matrix_d.getState( "root", "EEE" ) != X ) {
5664 if ( gl_matrix_d.getState( "3-4", "PPP" ) != G ) {
5668 catch ( final Exception e ) {
5669 e.printStackTrace( System.out );
5675 private static boolean testPaupLogParser( final File test_dir ) {
5677 final PaupLogParser parser = new PaupLogParser();
5678 parser.setSource( new File( test_dir + ForesterUtil.getFileSeparator() + "paup_log_test_1" ) );
5679 final CharacterStateMatrix<BinaryStates> matrix = parser.parse();
5680 if ( matrix.getNumberOfIdentifiers() != 8 ) {
5683 if ( !matrix.getIdentifier( 0 ).equals( "MOUSE" ) ) {
5686 if ( !matrix.getIdentifier( 1 ).equals( "NEMVE" ) ) {
5689 if ( !matrix.getIdentifier( 2 ).equals( "MONBE" ) ) {
5692 if ( !matrix.getIdentifier( 3 ).equals( "DICDI" ) ) {
5695 if ( !matrix.getIdentifier( 4 ).equals( "ARATH" ) ) {
5698 if ( !matrix.getIdentifier( 5 ).equals( "6" ) ) {
5701 if ( !matrix.getIdentifier( 6 ).equals( "7" ) ) {
5704 if ( !matrix.getIdentifier( 7 ).equals( "8" ) ) {
5707 if ( matrix.getNumberOfCharacters() != ( 66 + 66 + 28 ) ) {
5710 if ( matrix.getState( 0, 4 ) != BinaryStates.ABSENT ) {
5713 if ( matrix.getState( 0, 5 ) != BinaryStates.PRESENT ) {
5716 if ( matrix.getState( 1, 5 ) != BinaryStates.PRESENT ) {
5719 if ( matrix.getState( 7, 154 ) != BinaryStates.ABSENT ) {
5722 if ( matrix.getState( 7, 155 ) != BinaryStates.PRESENT ) {
5725 if ( matrix.getState( 7, 156 ) != BinaryStates.PRESENT ) {
5728 if ( matrix.getState( 7, 157 ) != BinaryStates.ABSENT ) {
5731 if ( matrix.getState( 7, 158 ) != BinaryStates.PRESENT ) {
5734 if ( matrix.getState( 7, 159 ) != BinaryStates.ABSENT ) {
5738 catch ( final Exception e ) {
5739 e.printStackTrace( System.out );