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

Diff of /FigKernelPackages/FigFam.pm

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

revision 1.30, Mon Jan 29 18:59:08 2007 UTC revision 1.31, Thu Feb 15 19:19:26 2007 UTC
# Line 24  Line 24 
24  use Carp;  use Carp;
25  use Data::Dumper;  use Data::Dumper;
26    
27  # This is the constructor.  Presumably, $class is 'FigFam'.  =head1 Module to access FIGfams
28  #  
29  # $fam_id is the ID of the family (of the form FIGnnnnnnn).  It is required.  =head3 new
30  #  
31  # $fam_data is optional.  If it exists,  usage:
32  # it gives the directory that is (or will) contain the FigFam data.  C<< my $figfam_obj = FigFam->new($fig, $fam_id, $fam_dir); >>
33  # $FIG_Config::data/FigfamsData will be used as a default.  
34  #  This is the constructor.  Presumably, C<$class> is 'FigFam'.
35  # $fam_file must exist within $fam_data.  It contains a 2-column version of the FIG families.  
36  # If the $fam_dir/yyy/FIGxxxxyyy directory (which is where the directory for the specific family  C<$fig> is an object reference created by a C<< FIG->new() >> constructor.
37  # will go) does not exist, the specification of the PEGs in $fam_file will be used to initialize  
38  # the family.  C<$fam_id> is the ID of the family, of the form C<FIGnnnnnn> where C<n> is a digit;
39  #  it is required.
40    
41    C<$fam_data> is optional.  If it is defined, it will be treated
42    as the directory that contains (or will contain) FigFam data.
43    If omitted, the FIGfam directory defaults to
44    C<$FIG_Config::data/FigfamsData>.
45    
46    A families file C<families.2c> must exist within C<$fam_data.>
47    It contains a 3-column tab-separated "tuple representation" of the FIG families,
48    of the form
49    C<<< FIGfam_IDE<lt>tabE<gt>FIG_Protein_IDE<lt>tabE<gt>Assigned_function. >>>
50    
51    If the C<$fam_dir/yyy/FIGxxxyyy> directory (which is where the subdirectory
52    where the specific family will go) does not exist, the specification of the PEGs
53    in C<$fam_file> will be used to initialize the family.
54    
55    =cut
56    
57  sub new {  sub new {
58      my($class,$fig,$fam_id,$fam_data) = @_;      my($class,$fig,$fam_id,$fam_data) = @_;
# Line 300  Line 316 
316      return $fam;      return $fam;
317  }  }
318    
319    
320    =head3 reset_function
321    
322    usage:
323    C<< $figfam_obj->reset_function(); >>
324    
325    Resets the function of a FIGfam to its "consensus function,"
326    where the weight of a vote toward the "consensus" is doubled
327    for PEGs connected to a subsytem.
328    
329    =cut
330    
331  sub reset_function {  sub reset_function {
332      my($self) = @_;      my($self) = @_;
333    
# Line 322  Line 350 
350      close(FUNC);      close(FUNC);
351  }  }
352    
353    
354    =head3 display
355    
356    usage:
357    C<< print $figfam_obj->display(); >>
358    
359    Returns a list-formatted table describing a family and its members.
360    
361    =cut
362    
363  sub display {  sub display {
364      my($self) = @_;      my($self) = @_;
365    
# Line 345  Line 383 
383      return join("\n", @disp) . "\n";      return join("\n", @disp) . "\n";
384  }  }
385    
386    
387    =head3 fasta_of
388    
389    usage:
390    
391    C<< $seqs_of_members = $figfam_obj->fasta_of(); >>
392    
393    or
394    
395    C<< $figfam_obj->fasta_of($filehandle_glob); >>
396    
397    Returns a ptr to a hash containing the sequences for all members of a FIGfam,
398    keyed by FIG feature ID (FID).
399    The filehandle glob is optional;
400    if included, the sequences will also print to the handle's file,
401    in fasta format.
402    
403    =cut
404    
405  sub fasta_of {  sub fasta_of {
406      my($self, $fh) = @_;      my($self, $fh) = @_;
407    
# Line 371  Line 428 
428      }      }
429  }  }
430    
431    
432    
433    =head3 ok_func
434    
435    usage:
436    C<< if ( &FigFam::ok_func( $fig, $func, $func2, $id2, $fam) ) { #...do something... } >>
437    
438    C<$fig> is an object constriucted by C<FIG->new()>.
439    
440    C<$func> and C<$func2> are two possible assigned functions.
441    
442    C<$id2> is the FIG ID (FID) of the PEG having function C<$func2>.
443    
444    C<$fam> is the family that C<$id2> is presumed to be a member of.
445    
446    Returns C<TRUE> is C<$func> and C$func2> are loosely "the same,"
447    or if C<$func> is judged to be "ignorable."
448    
449    =cut
450    
451  sub ok_func {  sub ok_func {
452      my($fig,$func,$func2,$id2,$fam) = @_;      my($fig,$func,$func2,$id2,$fam) = @_;
453    
# Line 395  Line 472 
472      return $fam->{ignorable_func}->{"$id2\t$func"}      return $fam->{ignorable_func}->{"$id2\t$func"}
473  }  }
474    
475    
476    =head3 member
477    
478    usage:
479    C<< if ( &FigFam::member($x, \@y)) { #...do something... } >>
480    
481    C<$x> is a scalar.
482    
483    C<\@y> is a ptr to a list.
484    
485    Returns C<TRUE> if C<$x> is in list C<@y>.
486    
487    =cut
488    
489  sub member {  sub member {
490      my($x,$yL) = @_;      my($x,$yL) = @_;
491      my $i;      my $i;
# Line 403  Line 494 
494      return ($i < @$yL);      return ($i < @$yL);
495  }  }
496    
497    
498    
499    =head3 list_members
500    
501    usage:
502    C<< @ids = $figfam_obj->list_members(); >>
503    
504    Returns a list of the PEG FIDs in a family.
505    
506    =cut
507    
508  sub list_members {  sub list_members {
509      my ($self)  = @_;      my ($self)  = @_;
510    
# Line 412  Line 514 
514      return @pegs;      return @pegs;
515  }  }
516    
517    
518    
519    =head3 loose_same_func
520    
521    usage:
522    
523    C<< if ( &FigFam::loose_same_func($f1, $f2) ) { #...do something... } >>
524    
525    C<$f1> and C<$f2> are function strings.
526    
527    Returns C<TRUE> if C<$f1> and C<$f2> are "more or less the same."
528    
529    =cut
530    
531  sub loose_same_func {  sub loose_same_func {
532      my($f1,$f2) = @_;      my($f1,$f2) = @_;
533    
# Line 434  Line 550 
550    
551    
552    
553    =head3 representatives
554    
555    usage:
556        C<< @rep_seqs = $figfam_obj->representatives(); >>
557    
558    Returns a list of the "representative sequences" characterizing a FIGfam.
559    
560    =cut
561    
562  sub representatives {  sub representatives {
563      my($self) = @_;      my($self) = @_;
564    
# Line 441  Line 566 
566      return @$reps;      return @$reps;
567  }  }
568    
569    
570    
571    =head3 should_be_member
572    
573    usage:
574    C<< if ( $figfam_obj->should_be_member( $seq ) ) { #...do something... } >>
575    
576    Returns C<TRUE> if the protein sequence in C<$seq> is judged to be
577    "similar enough" to the members of a family to potentially be included.
578    
579    =cut
580    
581  sub should_be_member {  sub should_be_member {
582      my($self,$seq,$debug) = @_;      my($self,$seq,$debug) = @_;
583    
# Line 515  Line 652 
652      return ($good,$sims);      return ($good,$sims);
653  }  }
654    
655    
656    
657    =head3 family_function
658    
659    usage:
660    C<< $func = $figfam_obj->family_function(); >>
661    
662    Returns the "consensus function" assigned to a FIGfam object.
663    
664    =cut
665    
666  sub family_function {  sub family_function {
667      my($self) = @_;      my($self) = @_;
668    
669      return $self->{function}      return $self->{function}
670  }  }
671    
672    
673    
674    =head3 family_id
675    
676    usage:
677    C<< $fam_id = $figfam_obj->family_id(); >>
678    
679    Returns the FIGfam ID of a FIGfam object.
680    
681    =cut
682    
683  sub family_id {  sub family_id {
684      my($self) = @_;      my($self) = @_;
685    
686      return $self->{id};      return $self->{id};
687  }  }
688    
689    
690    
691    =head3 family_dir
692    
693    usage:
694    
695    C<< $dir = &FigFam::family_dir( $fam_data, $fam_id ); >>
696    
697    Returns the path to the subdirectory of C<$fam_data>
698    that the FIGfam data for a FIGfam with ID C<$fam_id>
699    would be stored in.
700    
701    =cut
702    
703  sub fam_dir {  sub fam_dir {
704      my($fam_data,$fam_id) = @_;      my($fam_data,$fam_id) = @_;
705    

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3