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

View of /FigKernelPackages/Assignments.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (download) (as text) (annotate)
Wed Feb 15 22:12:26 2006 UTC (14 years ago) by overbeek
Branch: MAIN
Changes since 1.7: +67 -151 lines
minor fixes to assignment for close strains

#
# Copyright (c) 2003-2006 University of Chicago and Fellowship
# for Interpretations of Genomes. All Rights Reserved.
#
# This file is part of the SEED Toolkit.
# 
# The SEED Toolkit is free software. You can redistribute
# it and/or modify it under the terms of the SEED Toolkit
# Public License. 
#
# You should have received a copy of the SEED Toolkit Public License
# along with this program; if not write to the University of Chicago
# at info@ci.uchicago.edu or the Fellowship for Interpretation of
# Genomes at veronika@thefig.info or download a copy from
# http://www.theseed.org/LICENSE.TXT.
#

package Assignments;

use Carp;
use Data::Dumper;
use FIG;
use SameFunc;

sub default_parms {

    my $x = <<END
genome	198214.1	4	Shigella flexneri 2a str. 301
genome	198215.1	4	Shigella flexneri 2a str. 2457T
genome	216598.1	4	Shigella dysenteriae M131649
genome	216599.1	4	Shigella sonnei 53G
genome	630.2	4	Yersinia enterocolitica 8081
genome	633.2	4	Yersinia pseudotuberculosis (Livermore)
genome	187410.1	4	Yersinia pestis KIM
genome	214092.1	4	Yersinia pestis CO92
genome	229193.1	4	Yersinia pestis biovar Medievalis str. 91001
genome	273123.1	4	Yersinia pseudotuberculosis IP 32953
genome	594.1	4	Salmonella enterica subsp. enterica serovar Gallinarum
genome	99287.1	4	Salmonella typhimurium LT2
genome	119912.1	4	Salmonella enterica serovar Choleraesuis SC-B67
genome	209261.1	4	Salmonella enterica subsp. enterica serovar Typhi Ty2
genome	220341.1	4	Salmonella enterica subsp. enterica serovar Typhi str. CT18
genome	83333.1	4	Escherichia coli K12
genome	83334.1	4	Escherichia coli O157:H7
genome	155864.1	4	Escherichia coli O157:H7 EDL933
genome	199310.1	4	Escherichia coli CFT073
genome	216592.1	4	Escherichia coli 042
genome	216593.1	4	Escherichia coli E2348/69
genome	192222.1	4	Campylobacter jejuni subsp. jejuni NCTC 11168
genome	224308.1	2	Bacillus subtilis subsp. subtilis str. 168
external	sp	4
external	uni	1.3
external	kegg	1
subsystems	trusted	20
ABC_transporter_alkylphosphonate_(TC_3.A.1.9.1)	master:MattC
ABC_transporter_arabinose_(TC_3.A.1.2.2)	master:MattC
ABC_transporter_branched-chain_amino_acid_(TC_3.A.1.4.1)	master:MattC
ABC_transporter_dipeptide_(TC_3.A.1.5.2)	master:MattC
ABC_transporter_ferric_enterobactin_(TC_3.A.1.14.2)	master:MattC
ABC_transporter_ferrichrome_(TC_3.A.1.14.3)	master:MattC
ABC_transporter_galactose_(TC_3.A.1.2.3)	master:MattC
ABC_transporter_glutamate_aspartate_(TC_3.A.1.3.4)	master:MattC
ABC_transporter_glutamine_(TC_3.A.1.3.2)	master:MattC
ABC_transporter_glycerol_(TC_3.A.1.1.3)	master:MattC
ABC_transporter_heme_(TC3.A.1.107.1)	master:MattC
ABC_transporter_histidine_lysine_arginine_ornithine_(TC_3.A.1.3.1)	master:MattC
ABC_transporter_iron(III)_dicitrate_(TC_3.A.1.14.1)	master:MattC
ABC_transporter_Iron_(II)_and_Manganese	master:JenZ
ABC_transporter_L-proline_glycine_betaine_(TC_3.A.1.12.1)	master:MattC
ABC_transporter_macrolide	master:MattC
ABC_transporter_maltose	master:MattC
ABC_transporter_molybdenum_(TC_3.A.1.8.1)	master:MattC
ABC_transporter_nickel_(TC_3.A.1.5.3)	master:MattC
ABC_transporter_oligopeptide_(TC_3.A.1.5.1)	master:MattC
ABC_transporter_peptide_(TC_3.A.1.5.5)	master:MattC
ABC_transporter_phosphate_(TC_3.A.1.7.1)	master:MattC
ABC_transporter_polyamine_putrescine_spermidine_(TC_3.A.1.11.1)	master:MattC
ABC_transporter_putrescine_(TC_3.A.1.11.2)	master:MattC
ABC_transporter_ribose_(TC_3.A.1.2.1)	master:MattC
ABC_transporter_tungstate_(TC_3.A.1.6.2)	master:gjo
Accessory_Gene_Regulator	master:jcassat
Adhesion_of_Campylobacter	master:OlgaZ
Aerobactin_siderophore_biosynthesis	master:JenZ
Alanine_Biosynthesis	master:Straw
Alkanesulfonate_assimilation	master:OlgaV
Alkanesulfonates_Utilization	master:RobE
Allantoin_degradation	master:MattC
Ammonia_assimilation	master:EdF
Anaerobic_respiratory_reductases	master:OlgaV
Anthracycline_biosynthesis	master:OlgaV
Archease	master:gjo
Arginine_Biosynthesis	master:RickS
Arginine_Putrescine_and_4-aminobutyrate_degradation	master:MattC
Aromatic_Amin_Catabolism	master:OlgaV
Aromatic_amino_acid_degradation	master:OlgaV
Arsenic_resistance	master:JenZ
Asp-Glu-tRNA(Asn-Gln)_transamidation	master:gjo
Bacterial_Cell_Division	master:RickS
Bacterial_Chemotaxis	master:RickS
Bacteriocin-like_peptides_Blp	master:RamyA
Benzoate_degradation	master:OlgaV
Betaine_biosynthesis	master:MattC
Biogenesis_of_c-type_cytochromes	master:SvetaG
Biogenesis_of_cbb3-type_cytochrome_c_oxidases	master:SvetaG
Biotin_biosynthesis	master:rodionov
Biphenyl_Degradation	master:OlgaV
Branched-Chain_Amino_Acid_Biosynthesis	master:RossO
Butanol_Biosynthesis	master:RickS
Campylobacter_Iron_Metabolism	master:OlgaZ
Capsular_heptose_biosynthesis	master:OlgaZ
Capsular_polysaccharide_biosynthesis_in_Staphylococcus	master:JenZ
Capsular_Polysaccharide_Biosynthesis_in_Vibrio	master:JenZ
Capsular_surface_virulence_antigen_loci	master:JenZ
Carbon_monoxide_dehydrogenases	master:rodionov
carnitine_metabolism	master:MattC
Catechol_branch_of_beta-ketoadipate_pathway	master:OlgaV
CbiQO-type_ABC_transporter_systems	master:rodionov
Central_meta-cleavage_pathway_of_aromatic_compound_degradation	master:OlgaV
Chloroaromatic_degradation_pathway	master:OlgaV
Cholera_toxin	master:VeronikaV
Choline_Transport	master:RobE
Chorismate_Synthesis	master:VeronikaV
Clavulanic_acid_biosynthesis	master:OlgaV
CMP-N-acetylneuraminate_Biosynthesis	master:OlgaZ
Coagulation_cascade	master:rodionov
Cobalamin_synthesis	master:gjo
CobW	master:vcrecy
Coenzyme_A_Biosynthesis	master:AndreiO
Coenzyme_F420-H2_dehydrogenase_(methanophenazine)	master:gjo
Coenzyme_F420_hydrogenase	master:gjo
Coenzyme_F420_synthesis	master:gjo
Coenzyme_PQQ_synthesis	master:gjo
Colanic_acid_biosynthesis	master:JenZ
Cyanate_hydrolysis	master:gjo
Cyanobacterial_Circadian_Clock	master:OlgaZ
Cytochrome_B6-F_complex	master:SvetaG
Cytolethal_distending_toxin_of_Campylobacter_jejuni	master:OlgaZ
Cytolysin_and_Lipase_operon_in_Vibrio	master:JenZ
D-alanyl_lipoteichoic_acid_Biosynthesis	master:OlgaZ
D-arabinose_degradation	master:MattC
D-galactarate_degradation	master:MattC
D-galacturonate_degradation	master:MattC
D-tyrosyl-tRNA(Tyr)_deacylase	master:gjo
De_Novo_Purine_Biosynthesis	master:RossO
De_Novo_Pyrimidine_Synthesis	master:RossO
Denitrification	master:rodionov
Di-Inositol-Phosphate_biosynthesis	master:rodionov
DNA-replication	master:RickS
DNA_repair,_bacterial	master:gjo
DNA_repair_and_recombination_eukaryotic	master:gjo
DNA_replication,_archaeal	master:gjo
DNA_structural_proteins,_bacterial	master:gjo
DNA_topoisomerases	master:gjo
DNA_topoisomerases,_Type_I,_ATP-independent	master:gjo
DNA_topoisomerases,_Type_II,_ATP-dependent	master:gjo
dTDP-rhamnose_synthesis	master:MikeK
Embden-Meyerhof_and_Gluconeogenesis	master:SvetaG
Energy-conserving_hydrogenase_(ferredoxin)	master:gjo
Entner-Doudoroff_Pathway	master:SvetaG
ESAT-6_proteins_secretion_system_in_Actinobacteria	master:SvetaG
ESAT-6_proteins_secretion_system_in_Firmicutes	master:SvetaG
Ethanolamine_utilization	master:gjo
F0F1-type_ATP_synthase	master:RickS
Fatty_Acid_Biosynthesis_FASII	master:AndreiO
Fe-S_cluster_assembly	master:rodionov
Fermentations:_Lactate	master:SvetaG
Fermentations:_Mixed_acid	master:SvetaG
Flagellum	master:RickS
Flagellum_in_Campylobacter	master:JenZ
FMN_and_FAD_biosynthesis	master:AndreiO
Folate_Biosynthesis	master:vcrecy
Formaldehyde_assimilation:_Ribulose_monophosphate_pathway	master:SvetaG
Formate_dehydrogenase	master:gjo
Formate_hydrogenase	master:OlgaV
Glycerol_fermenation_to_1,3-propanediol	master:gjo
Glycerolipid_and_glycerphospholipid_metabolism	master:VasiliyP_UCSD
Glycine_reductase,_sarcosine_reductase_and_betaine_reductase	master:gjo
Glycine_synthesis	master:MikeK
Glyoxylate_Synthesis	master:RickS
GroEL_GroES	master:MikeK
Heme-bound_Iron_Scavenge_Pathway	master:RickS
Hfl_operon	master:gjo
Histidine_Biosynthesis	master:RossO
Histidine_Degradation	master:RossO
HMG_CoA_Synthesis	master:VeronikaV
Homogentisate_pathway_of_aromatic_compound_degradation	master:OlgaV
Hydantoin_metabolism	master:OlgaV
Hydrogenases	master:OlgaV
Hyperosmotic_ectoine_biosynthesis	master:JenZ
Inositol_catabolism	master:VeronikaV
Inteins	master:gjo
Isoprenoid_Biosynthesis	master:OlgaZ
KDO2-Lipid_A_biosynthesis	master:OlgaZ
L-ascorbate_utilization_(and_related_gene_clusters)	master:SvetaG
Lactate_utilization	master:rodionov
Lactose_utilization	master:gjo
Leucine_Degradation_and_HMG-CoA_Metabolism	master:VeronikaV
Lipoic_acid_metabolism	master:gjo
Lipopolysaccharide_biosynthesis_2	master:OlgaV
Listeria_Pathogenicity_Island_LIPI-1_extended	master:SvetaG
Listeria_surface_proteins:_Internalin-like_proteins	master:SvetaG
Listeria_surface_proteins:_LPXTG_motif	master:SvetaG
LMPTP_YfkJ_cluster	master:AndreiO
LMPTP_YwlE_cluster	master:AndreiO
LOS_core_oligosaccharide_biosynthesis	master:OlgaZ
Lysine_Biosynthesis_DAP_Pathway	master:AndreiO
Malonate_decarboxylase	master:VeronikaV
Mannose-sensitive_hemagglutinin_type_4_pilus	master:RobE
Mannose_and_fructose_metabolism	master:HanYuC_UCSD
Membrane-bound_Ni,_Fe-hydrogenase	master:rodionov
Mercury_resistance_operon	master:JenZ
Methanogenesis	master:gjo
Methanogenesis_from_methylated_compounds	master:gjo
Methanophenazine_hydrogenase	master:gjo
Methicillin_resistance_in_Staphylococci	master:SvetaG
Methionine_Biosynthesis	master:rodionov
Methionine_Salvage	master:gjo
MLST	master:RobE
Molybdopterin_biosynthesis	master:JenZ
Motility_of_Campylobacter	master:OlgaZ
N-Acetyl-D-Glucosamine_Utilization	master:OlgaZ
N-linked_Glycosylation_in_Bacteria	master:OlgaZ
n-Phenylalkanoic_acid_degradation	master:OlgaV
Na(+)-translocating_NADH-quinone_oxidoreductase_and_rnf-like_group_of_electron_transport_complexes	master:OlgaV
NAD_and_NADP_cofactor_biosynthesis_global	master:AndreiO
NAG_short	master:rodionov
NiFe_hydrogenase_maturation	master:gjo
Nitrate_and_nitrite_ammonification	master:rodionov
Nitrosative_stress	master:rodionov
Nudix_proteins_(nucleoside_triphosphate_hydrolases)	master:gjo
NusA-TFII_Cluster	master:gjo
One-carbon_metabolism_by_tetrahydropterines	master:OlgaV
Osmotically_activated_L-carnitine_ABC_transporter_in_Listeria	master:JenZ
Oxidative_stress	master:OlgaV
p-Hydroxybenzoate_degradation	master:OlgaV
Pentose_phosphate_pathway	master:SvetaG
Peptidoglycan_Biosynthesis	master:RickS
Peptidyl-prolyl_cis-trans_isomerase	master:gjo
Phenylacetate_pathway_of_aromatic_compound_degradation	master:OlgaV
Phenylalanine_synthesis	master:MikeK
Phenylpropionate_Degradation	master:OlgaV
Phosphorylcholine_incorporation_in_LPS	master:OlgaZ
Phosphotransferase_enzyme_II_-_Glucose_class_permease	master:JenZ
Phosphotransferase_enzyme_II_-_Lactose_class_permease	master:JenZ
Phosphotransferase_enzyme_II_-_Mannitol_class_permease	master:JenZ
Phosphotransferase_enzyme_II_-_Mannose_family_permease	master:JenZ
Photosystem_I	master:SvetaG
Photosystem_II	master:SvetaG
PnuC-like_transporters	master:rodionov
Polyadenylation_bacterial	master:gjo
Polyhydroxybutyrate_metabolism	master:OlgaV
Porphyrin,_Heme,_and_Siroheme_Biosynthesis	master:SvetaG
ppGpp_biosynthesis	master:MikeK
Proline_reductase	master:gjo
Proline_Synthesis	master:RickS
Propanediol_utilization	master:gjo
Prophage-encoded_Exotoxins	master:RamyA
Proteasome_archaeal	master:gjo
Proteasome_eukaryotic	master:gjo
Protein_degradation	master:gjo
Protocatechuate_branch_of_beta-ketoadipate_pathway	master:OlgaV
Pterin_biosynthesis	master:vcrecy
Purine_conversions	master:OlgaV
Purine_Utilization	master:OlgaV
Putative_sulfate_assimilation_cluster	master:OlgaV
Pyridoxin_(Vitamin_B6)_Biosynthesis	master:OlgaZ
Pyruvate:ferredoxin_oxidoreductase	master:SvetaG
Pyruvate_Alanine_Serine_Interconversions	master:JasonS_UCSD
Pyruvate_metabolism_I:_anaplerotic_reactions,_PEP	master:SvetaG
Pyruvate_metabolism_II:_acetyl-CoA,_acetogenesis_from_pyruvate	master:SvetaG
Queuosine-Archaeosine_Biosynthesis	master:vcrecy
Quorum_Sensing:_Autoinducer-2_Synthesis	master:AndrewJ
Respiratory_Complex_I	master:OlgaV
Respiratory_dehydrogenases_1	master:OlgaV
Riboflavin_metabolism	master:rodionov
Ribonuclease_P_archaeal_and_eukaryal	master:gjo
Ribonucleotide_reduction	master:rodionov
Ribosome_biogenesis_bacterial	master:gjo
Ribosome_LSU_bacterial	master:gjo
Ribosome_LSU_chloroplast	master:gjo
Ribosome_LSU_eukaryotic_and_archaeal	master:gjo
Ribosome_LSU_mitochondrial	master:gjo
Ribosome_SSU_bacterial	master:gjo
Ribosome_SSU_chloroplast	master:gjo
Ribosome_SSU_eukaryotic_and_archaeal	master:gjo
Ribosome_SSU_mitochondrial	master:gjo
RNA_3'-terminal_phosphate_cyclase	master:gjo
RNA_polymerase_archaeal	master:gjo
RNA_polymerase_archaeal_initiation_factors	master:gjo
RNA_polymerase_bacterial	master:gjo
RNA_polymerase_chloroplast	master:gjo
RNA_polymerase_I	master:gjo
RNA_polymerase_II	master:gjo
RNA_polymerase_II_initiation_factors	master:gjo
RNA_polymerase_III	master:gjo
Rrf2_family_transcriptional_regulators	master:rodionov
SA:14-24	master:RossO
Salicylate_ester_degradation	master:OlgaV
Selenocysteine_metabolism	master:gjo
Serine-glyoxylate_cycle	master:OlgaV
Serine_Biosynthesis	master:MikeK
Sialic_Acid_Metabolism	master:OlgaZ
Sodium_Hydrogen_Antiporter	master:JenZ
Soluble_cytochromes_and_functionally_related_electron_carriers	master:OlgaV
SpeB-SpeF_extended_regulon	master:RamyA
Spliceosome	master:gjo
Spore_Coat	master:RickS
Streptococcal_Mga_Regulon	master:RamyA
Streptococcus_pneumoniae_Vancomycin_Tolerance_Locus	master:RamyA
Streptococcus_pyogenes_recombinatorial_zone	master:RamyA
Streptococcus_pyogenes_Virulome	master:RamyA
Streptolysin_S_Biosynthesis_and_Transport	master:RamyA
Streptomycin_biosynthesis	master:OlgaV
Succinate_dehydrogenase	master:OlgaV
Sugar-phosphate_stress_regulation	master:gjo
Sulfate_to_Sulfide	master:RobE
Taurine_Utilization	master:RobE
TCA_Cycle	master:OlgaV
Teichoic_and_lipoteichoic_acids_biosynthesis	master:OlgaV
Teichuronic_acid_biosynthesis	master:OlgaV
Terminal_cytochrome_C_oxidases	master:OlgaV
Terminal_cytochrome_oxidases	master:OlgaV
Tetrathionate_respiration	master:gjo
The_Tartronate_Semialdehyde_Hub	master:RossO
Thiamin_biosynthesis	master:rodionov
Thioredoxin-disulfide_reductase	master:gjo
Threonine_degradation	master:OlgaV
Threonine_synthesis	master:MikeK
Transcription_factors_bacterial	master:gjo
Transcription_factors_cyanobacterial_RpoD-like_sigma_factors	master:gjo
Translation_elongation_factors_eukaryotic_and_archaeal	master:gjo
Translation_factors_bacterial	master:gjo
Translation_initiation_factors_eukaryotic_and_archaeal	master:gjo
Transport_of_Nickel_and_Cobalt	master:rodionov
Tricarballylate_Utilization	master:RossO
tRNA_aminoacylation	master:gjo
tRNA_aminoacylation,_mitochondrial	master:gjo
tRNA_processing	master:gjo
tRNA_splicing	master:gjo
Tryptophan_synthesis	master:VeronikaV
Two-component_regulatory_systems_in_Campylobacter	master:OlgaZ
Tyrosine_synthesis	master:MikeK
Ubiquinone_Biosynthesis	master:OlgaZ
Ubiquinone_Menaquinone-cytochrome_c_reductase_complexes	master:OlgaV
UDP-N-acetylmuramate_from_Fructose-6-phosphate_Biosynthesis	master:vasiliyP
Universal_GTPases	master:gjo
Urea_decomposition	master:rodionov
Utilization_of_glutathione_as_a_sulphur_source	master:OlgaV
V-Type_ATP_synthase	master:RickS
Vibrio_pathogenicity_island	master:JenZ
Wyeosine-MimG_Biosynthesis	master:vcrecy
Xylose_utilization	master:rodionov
yrdC	master:vcrecy
//
END
;
    return split(/\n/,$x);
}


sub choose_best_assignment {
    my($fig,$parms,$pegs,$external_ids) = @_;
    my($peg,$id);

    my $functions = {};
    foreach $peg (@$pegs)
    {
	&load_peg_function($fig,$parms,$peg,$functions);
    }

    foreach $id (@$external_ids)
    {
	&load_ext_function($fig,$parms,$id,$functions);
    }

    return &cleanup(&pick_function($fig,$parms,$functions));
}


sub cleanup {
    my($func) = @_;

    if (! $func)                                           { return "hypothetical protein" }
    if ($func =~ /^hypothetical (\S+ )?protein .*$/i)      { return "hypothetical protein" }
    if ($func =~ /^[a-zA-Z]{1,2}\d{2,5}( protein)?$/i)     { return "hypothetical protein" }
    if ($func =~ /^similar to ORF\d+$/)                    { return "hypothetical protein" }
    if ($func =~ /^(Alr|As|All|Tlr|Tll|Glr|Blr|Slr|SEW|pANL)\d+( protein)?$/i) { return "hypothetical protein" }
    if ($func =~ /^\d{5}/)                                 { return "hypothetical protein" }
    if ($func =~ /unknown protein/)                        { return "hypothetical protein" }
    
    return $func;
}

sub pick_function {
    my($fig,$parms,$functions) = @_;
    my($set,$score,$best_source,$poss_function);
    my(@scored);

    my @partitions = &SameFunc::group_funcs(keys(%$functions));
    if ($ENV{'VERBOSE'}) {  print STDERR "partition: ",&Dumper(\@partitions,$functions); }

    foreach $set (@partitions)
    {
	$score = &score_set($set,$functions);
#	print STDERR &Dumper([$score,$set]);

#       print STDERR "picking from set ",&Dumper($set);
	($poss_function,$best_source) = &pick_specific($fig,$parms,$set,$functions);
#	print STDERR "picked $poss_function from $best_source\n";
	push(@scored,[$score,$poss_function,$best_source]);
    }
    @scored = sort { $b->[0] <=> $a->[0] } @scored;

    if ((@scored > 1) && $ENV{'VERBOSE'})
    {
	foreach $_ (@scored)
	{
	    print STDERR join("\t",@$_),"\n";
	}
	print STDERR "//\n";
    }
    return (@scored > 0) ? $scored[0]->[1] : "";
}

sub score_set {
    my($set,$functions) = @_;
    my($func,$x);

    my $score = 0;
    foreach $func (@$set)
    {
	if ($x = $functions->{$func})
	{
	    foreach $_ (@$x)
	    {
		$score += $_->[0];
	    }
	}
    }
    return $score;
}

sub pick_specific {
    my($fig,$parms,$set,$functions) = @_;
    my($best_func,$best_score,$func,$x,$best_source);

    $best_func  = "";
    $best_score = 0;
    $best_source = "";

    foreach $func (@$set)
    {
	if ($x = $functions->{$func})
	{
	    my $incr = @$x;
	    foreach $_ (@$x)
	    {
		my($sc,$peg,$in_sub) = @$_;
		$sc += $in_sub ? 10000 : 0;

		if (((100 * $sc) + $incr) > $best_score)
		{
		    $best_score = (100 * $sc) + $incr;
		    $best_func  = $func;
		    $best_source = $peg;
		}
	    }
	}
    }
    if ($ENV{'VERBOSE'}) { print STDERR &Dumper(["picked best source",$set,$functions,$best_func,$best_source]) }
    return ($best_func,$best_source);
}

sub load_ext_function {
    my($fig,$parms,$id,$functions) = @_;

    my $func = $fig->function_of($id);
    if ($func && # (! &FIG::hypo($func)) && 
	($id =~ /^([A-Za-z]{2,4})\|/) && ($_ = $parms->{'external'}->{$1}))
    {
	push(@{$functions->{$func}},[$_,$id]);
    }
}

sub load_peg_function {
    my($fig,$parms,$peg,$functions) = @_;

    my $func = $fig->function_of($peg);
    if ($func) # (! &FIG::hypo($func))
    {
	my $value = 1;

	my $genome = &FIG::genome_of($peg);
	if ($_ = $parms->{'genome'}->{$genome})
	{
	    $value += $_;
	}

	my $subv = 0;
	my @subs = $fig->peg_to_subsystems($peg);
	my $sub;
	my $in_sub = 0;
	foreach $sub (@subs)
	{
	    if ($_ = $parms->{'subsystems'}->{$sub})
	    {
		if ($_ > $subv)
		{
		    $subv = $_;
		}
		$in_sub = 1;
	    }
	}
	$value += $subv;
	push(@{$functions->{$func}},[$value,$peg,$in_sub]);
    }
}

sub equivalent_ids {
    my($fig,$parms,$pegs) = @_;
    my($peg,@aliases,$alias,%external_ids,%pegs,$tuple);

    foreach $peg (@$pegs)
    {
	$pegs{$peg} = 1;
	@aliases = $fig->feature_aliases($peg);
	foreach $alias (@aliases)
	{
	    if (($alias =~ /^([A-Za-z]{2,4})\|\S+$/) && $parms->{"external"}->{$1})
	    {
		$external_ids{$alias} = 1;
	    }
	}
	foreach $tuple ($fig->mapped_prot_ids($peg))
	{
	    if (($tuple->[0] =~ /^fig\|/) && $fig->is_real_feature($tuple->[0]))
	    {
		$pegs{$tuple->[0]} = 1;
	    }
	    elsif (($tuple->[0] =~ /^([A-Za-z]{2,4})\|\S+$/) && $parms->{"external"}->{$1})
	    {
		$external_ids{$tuple->[0]} = 1;
	    }
	}
    }
    return ([sort { &FIG::by_fig_id($a,$b) }  keys(%pegs)],[sort keys(%external_ids)]);
}

sub load_parms {
    my($parmsF) = @_;
    my @parmsS;

    my $wts = {};

    if ($parmsF)
    {
	@parmsS = `cat $parmsF`;
    }
    else
    {
	@parmsS = &default_parms;
    }
    while ($_ = shift @parmsS)
    {
	chomp;
	my($type,$data,$val) = split(/\t/,$_);
	if ($type eq 'subsystems')
	{
	    my $x;
	    while (($x = shift @parmsS) && ($x !~ /^\/\//))
	    {
		if ($x =~ /^(\S[^\t]+\S)/)
		{
		    $wts->{$type}->{$1} = $val;
		}
	    }
	}
	else
	{
	    $wts->{$type}->{$data} = $val;
	}
    }
    return $wts;
}

sub print_parms {
    my($parms) = @_;
    my($type,$data,$val,$wt_by_type);

    print STDERR "Parameters:\n";
    foreach $type (sort keys(%$parms))
    {
	print STDERR "\n\t$type\n";
	$wt_by_type = $parms->{$type};
	foreach $data (sort keys(%$wt_by_type))
	{
	    $val = $wt_by_type->{$data};
	    print STDERR "\t\t$data\t$val\n";
	}
    }
    print STDERR "\n";
}


1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3