[Bio] / FigKernelPackages / FIG.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/FIG.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.129, Sun Aug 1 11:50:25 2004 UTC revision 1.130, Mon Aug 2 20:02:29 2004 UTC
# Line 1784  Line 1784 
1784      return "";      return "";
1785  }  }
1786    
1787    #
1788    #  Support for colorizing organisms by domain
1789    #  -- GJO
1790    #
1791    =pod
1792    
1793    =head1 genus_species_domain
1794    
1795    usage: ($gs, $domain) = $fig->genus_species_domain($genome_id)
1796    
1797    Returns the genus and species (and strain if that has been properly recorded)
1798    in a printable form, and domain.
1799    
1800    =cut
1801    
1802    sub genus_species_domain {
1803        my ($self, $genome) = @_;
1804    
1805        my $genus_species_domain = $self->cached('_genus_species_domain');
1806        if ( ! $genus_species_domain->{ $genome } )
1807        {
1808            my $rdbH = $self->db_handle;
1809            my $relational_db_response = $rdbH->SQL("SELECT genome,gname,maindomain FROM genome");
1810            my $triple;
1811            foreach $triple ( @$relational_db_response )
1812            {
1813                $genus_species_domain->{ $triple->[0] } = [ $triple->[1], $triple->[2] ];
1814            }
1815        }
1816        my $gsdref = $genus_species_domain->{ $genome };
1817        return $gsdref ? @$gsdref : ( "", "" );
1818    }
1819    
1820    
1821    my %domain_color = ( AR => "#DDFFFF", BA => "#FFDDFF", EU => "#FFFFDD",
1822                         VI => "#DDDDDD", EN => "#BBBBBB" );
1823    
1824    sub domain_color {
1825        my ($domain) = @_;
1826        defined $domain || return "#FFFFFF";
1827        return $domain_color{ uc substr($domain, 0, 2) } || "#FFFFFF";
1828    }
1829    
1830    
1831    =pod
1832    
1833    =head1 org_and_color_of
1834    
1835    usage: ($org, $color) = $fig->org_and_domain_of($prot_id)
1836    
1837    Return the best guess organism and domain html color string of an organism.
1838    In the case of external proteins, we can usually determine an organism, but not
1839    anything more precise than genus/species (and often not that).  This routine takes
1840    a protein ID (which may be a feature ID) and returns "the organism".
1841    
1842    =cut
1843    
1844    sub org_and_color_of {
1845        my($self,$prot_id) = @_;
1846        my $relational_db_response;
1847        my $rdbH = $self->db_handle;
1848    
1849        if ($prot_id =~ /^fig\|/)
1850        {
1851            my( $gs, $domain ) = $self->genus_species_domain($self->genome_of($prot_id));
1852            return ( $gs, domain_color( $domain ) );
1853        }
1854    
1855        if (($relational_db_response = $rdbH->SQL("SELECT org FROM external_orgs WHERE ( prot = \'$prot_id\' )")) &&
1856            (@$relational_db_response >= 1))
1857        {
1858            return ($relational_db_response->[0]->[0], "#FFFFFF");
1859        }
1860        return ("", "#FFFFFF");
1861    }
1862    
1863    #
1864    #  End of support for colorizing organisms by domain
1865    #  -- GJO
1866    #
1867    
1868  =pod  =pod
1869    
1870  =head1 abbrev  =head1 abbrev

Legend:
Removed from v.1.129  
changed lines
  Added in v.1.130

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3