public static final double MAX_SIMILARITY_SCORE = 1.0;
public static final double MIN_SIMILARITY_SCORE = 0.0;
+ private Set<BinaryDomainCombination> _all_binary_domain_combinations;
+ private Set<String> _all_domains;
+ private boolean _allow_domains_to_be_ignored;
+ private Set<BinaryDomainCombination> _binary_domain_combinations_specific_to_0;
+ private Set<BinaryDomainCombination> _binary_domain_combinations_specific_to_1;
final private GenomeWideCombinableDomains _combinable_domains_genome_0;
final private GenomeWideCombinableDomains _combinable_domains_genome_1;
private Set<String> _domain_ids_to_ignore;
- private boolean _allow_domains_to_be_ignored;
- private Set<String> _all_domains;
- private Set<String> _shared_domains;
private Set<String> _domains_specific_to_0;
private Set<String> _domains_specific_to_1;
- private Set<BinaryDomainCombination> _all_binary_domain_combinations;
private Set<BinaryDomainCombination> _shared_binary_domain_combinations;
- private Set<BinaryDomainCombination> _binary_domain_combinations_specific_to_0;
- private Set<BinaryDomainCombination> _binary_domain_combinations_specific_to_1;
+ private Set<String> _shared_domains;
public DomainArchitectureBasedGenomeSimilarityCalculator( final GenomeWideCombinableDomains combinable_domains_genome_0,
final GenomeWideCombinableDomains combinable_domains_genome_1 ) {
setDomainIdsToIgnore( new HashSet<String>() );
}
- private void forceRecalculation() {
- _all_domains = null;
- _shared_domains = null;
- _domains_specific_to_0 = null;
- _domains_specific_to_1 = null;
- _all_binary_domain_combinations = null;
- _shared_binary_domain_combinations = null;
- _binary_domain_combinations_specific_to_0 = null;
- _binary_domain_combinations_specific_to_1 = null;
- }
-
/**
* Does not return binary combinations which contain one or two domains
* to be ignored -- if ignoring is allowed.
return _all_domains;
}
- private Set<BinaryDomainCombination> getBinaryDomainCombinationsSpecificToGenome( final boolean specific_to_genome_0 ) {
- final Set<BinaryDomainCombination> specific = new HashSet<BinaryDomainCombination>();
- final Set<BinaryDomainCombination> bc0 = getCombinableDomainsGenome0().toBinaryDomainCombinations();
- final Set<BinaryDomainCombination> bc1 = getCombinableDomainsGenome1().toBinaryDomainCombinations();
- if ( specific_to_genome_0 ) {
- for( final BinaryDomainCombination binary_domain_combination0 : bc0 ) {
- if ( !bc1.contains( binary_domain_combination0 ) ) {
- specific.add( binary_domain_combination0 );
- }
- }
- }
- else {
- for( final BinaryDomainCombination binary_domain_combination1 : bc1 ) {
- if ( !bc0.contains( binary_domain_combination1 ) ) {
- specific.add( binary_domain_combination1 );
- }
- }
- }
- if ( isAllowDomainsToBeIgnored() && !getDomainIdsToIgnore().isEmpty() ) {
- return pruneBinaryCombinations( specific );
- }
- return specific;
- }
-
public Set<BinaryDomainCombination> getBinaryDomainCombinationsSpecificToGenome0() {
if ( _binary_domain_combinations_specific_to_0 == null ) {
_binary_domain_combinations_specific_to_0 = getBinaryDomainCombinationsSpecificToGenome( true );
return _binary_domain_combinations_specific_to_1;
}
- private GenomeWideCombinableDomains getCombinableDomainsGenome0() {
- return _combinable_domains_genome_0;
- }
-
- private GenomeWideCombinableDomains getCombinableDomainsGenome1() {
- return _combinable_domains_genome_1;
- }
-
- private Set<String> getDomainIdsToIgnore() {
- return _domain_ids_to_ignore;
- }
-
- private Set<String> getDomainsSpecificToGenome( final boolean specific_to_genome_0 ) {
- final Set<String> specific = new HashSet<String>();
- final Set<String> d0 = getCombinableDomainsGenome0().getAllDomainIds();
- final Set<String> d1 = getCombinableDomainsGenome1().getAllDomainIds();
- if ( specific_to_genome_0 ) {
- for( final String domain0 : d0 ) {
- if ( !d1.contains( domain0 ) ) {
- specific.add( domain0 );
- }
- }
- }
- else {
- for( final String domain1 : d1 ) {
- if ( !d0.contains( domain1 ) ) {
- specific.add( domain1 );
- }
- }
- }
- if ( isAllowDomainsToBeIgnored() && !getDomainIdsToIgnore().isEmpty() ) {
- return pruneDomains( specific );
- }
- return specific;
- }
-
public Set<String> getDomainsSpecificToGenome0() {
if ( _domains_specific_to_0 == null ) {
_domains_specific_to_0 = getDomainsSpecificToGenome( true );
return _shared_domains;
}
+ public void setAllowDomainsToBeIgnored( final boolean allow_domains_to_be_ignored ) {
+ forceRecalculation();
+ _allow_domains_to_be_ignored = allow_domains_to_be_ignored;
+ }
+
+ void setDomainIdsToIgnore( final Set<String> domain_ids_to_ignore ) {
+ forceRecalculation();
+ _domain_ids_to_ignore = domain_ids_to_ignore;
+ }
+
+ private void forceRecalculation() {
+ _all_domains = null;
+ _shared_domains = null;
+ _domains_specific_to_0 = null;
+ _domains_specific_to_1 = null;
+ _all_binary_domain_combinations = null;
+ _shared_binary_domain_combinations = null;
+ _binary_domain_combinations_specific_to_0 = null;
+ _binary_domain_combinations_specific_to_1 = null;
+ }
+
+ private Set<BinaryDomainCombination> getBinaryDomainCombinationsSpecificToGenome( final boolean specific_to_genome_0 ) {
+ final Set<BinaryDomainCombination> specific = new HashSet<BinaryDomainCombination>();
+ final Set<BinaryDomainCombination> bc0 = getCombinableDomainsGenome0().toBinaryDomainCombinations();
+ final Set<BinaryDomainCombination> bc1 = getCombinableDomainsGenome1().toBinaryDomainCombinations();
+ if ( specific_to_genome_0 ) {
+ for( final BinaryDomainCombination binary_domain_combination0 : bc0 ) {
+ if ( !bc1.contains( binary_domain_combination0 ) ) {
+ specific.add( binary_domain_combination0 );
+ }
+ }
+ }
+ else {
+ for( final BinaryDomainCombination binary_domain_combination1 : bc1 ) {
+ if ( !bc0.contains( binary_domain_combination1 ) ) {
+ specific.add( binary_domain_combination1 );
+ }
+ }
+ }
+ if ( isAllowDomainsToBeIgnored() && !getDomainIdsToIgnore().isEmpty() ) {
+ return pruneBinaryCombinations( specific );
+ }
+ return specific;
+ }
+
+ private GenomeWideCombinableDomains getCombinableDomainsGenome0() {
+ return _combinable_domains_genome_0;
+ }
+
+ private GenomeWideCombinableDomains getCombinableDomainsGenome1() {
+ return _combinable_domains_genome_1;
+ }
+
+ private Set<String> getDomainIdsToIgnore() {
+ return _domain_ids_to_ignore;
+ }
+
+ private Set<String> getDomainsSpecificToGenome( final boolean specific_to_genome_0 ) {
+ final Set<String> specific = new HashSet<String>();
+ final Set<String> d0 = getCombinableDomainsGenome0().getAllDomainIds();
+ final Set<String> d1 = getCombinableDomainsGenome1().getAllDomainIds();
+ if ( specific_to_genome_0 ) {
+ for( final String domain0 : d0 ) {
+ if ( !d1.contains( domain0 ) ) {
+ specific.add( domain0 );
+ }
+ }
+ }
+ else {
+ for( final String domain1 : d1 ) {
+ if ( !d0.contains( domain1 ) ) {
+ specific.add( domain1 );
+ }
+ }
+ }
+ if ( isAllowDomainsToBeIgnored() && !getDomainIdsToIgnore().isEmpty() ) {
+ return pruneDomains( specific );
+ }
+ return specific;
+ }
+
private void init() {
deleteAllDomainIdsToIgnore();
setAllowDomainsToBeIgnored( false );
}
return pruned;
}
-
- public void setAllowDomainsToBeIgnored( final boolean allow_domains_to_be_ignored ) {
- forceRecalculation();
- _allow_domains_to_be_ignored = allow_domains_to_be_ignored;
- }
-
- void setDomainIdsToIgnore( final Set<String> domain_ids_to_ignore ) {
- forceRecalculation();
- _domain_ids_to_ignore = domain_ids_to_ignore;
- }
}
\ No newline at end of file