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

Diff of /FigKernelPackages/FigGFF.pm

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

revision 1.5, Fri Apr 8 20:22:23 2005 UTC revision 1.6, Sat Apr 9 17:21:15 2005 UTC
# Line 134  Line 134 
134    
135      map { $default_options->{$_} = $options{$_} } keys(%options);      map { $default_options->{$_} = $options{$_} } keys(%options);
136    
137        # added contig_start_cache and contig_end_cache because we have something like
138        # sequence-region   contigname      1       10000
139        # in general we will set contig_start_cache == 1
140        # and contig_end_cache == contig_length_cache
141    
142      my $self = {      my $self = {
143          options => $default_options,          options => $default_options,
144          contig_length_cache => {},          contig_length_cache => {},
145            contig_start_cache  => {},
146            contig_end_cache    => {},
147          fig => $fig,          fig => $fig,
148      };      };
149    
# Line 662  Line 669 
669  {  {
670      my($self, $directive, $rest) = @_;      my($self, $directive, $rest) = @_;
671    
672        $directive = lc($directive);
673        my @rest=split /\t/, $rest;
674    
675        if ($directive eq "genome")
676        {
677            $self->current_file->genome_id($rest[0]);
678            $self->current_file->genome_name($rest[1]);
679        }
680        elsif ($directive eq "genome_md5")
681        {
682            $self->current_file->set_genome_checksum(@rest[0,1]);
683        }
684        elsif ($directive eq "origin")
685        {
686            print STDERR "We have a directive called origin but this should be changed as it will conflict with NCBI's ORIGIN indicating beginning of the sequence\n";
687            print STDERR "At the moment ORIGIN is returned by \$feat->project\n";
688            $self->current_file->project($rest[0]);
689        }
690        elsif ($directive eq "taxonomy")
691        {
692            $self->current_file->taxonomy($rest);
693        }
694        elsif ($directive eq "sequence-region")
695        {
696            $self->{contig_length_cache}->{$rest[0]}=$rest[2]-$rest[1];
697            $self->{contig_start_cache}->{$rest[0]}=$rest[1];
698            $self->{contig_end_cache}->{$rest[0]}=$rest[2];
699        }
700        else
701        {
702      print "Have gff3 directive '$directive' rest='$rest'\n";      print "Have gff3 directive '$directive' rest='$rest'\n";
703  }  }
704    
705    }
706    
707  sub parse_seed_directive  sub parse_seed_directive
708  {  {
709      my($self, $rest) = @_;      my($self, $rest) = @_;
710    
711      my($verb, @rest) = split(/\t/, $rest);      my($verb, @rest) = split(/\t/, $rest);
712    
713        # are we case sensitive? I don't think so
714        $verb-lc($verb);
715    
716      if ($verb eq "anno_start")      if ($verb eq "anno_start")
717      {      {
718          $self->current_file->anno_start($rest[0]);          $self->current_file->anno_start($rest[0]);
# Line 679  Line 721 
721      {      {
722          $self->current_file->anno_start($rest[0]);          $self->current_file->anno_start($rest[0]);
723      }      }
     elsif ($verb eq "genome_md5")  
     {  
         $self->current_file->set_genome_checksum(@rest[0,1]);  
     }  
724      elsif ($verb eq "contig_md5")      elsif ($verb eq "contig_md5")
725      {      {
726          $self->current_file->set_contig_checksum(@rest[0,1,2]);          $self->current_file->set_contig_checksum(@rest[0,1,2]);
# Line 934  Line 972 
972      my $self = {      my $self = {
973          fig => $fig,          fig => $fig,
974          features => [],          features => [],
975            contigs  => [],
976          feature_index => {},          feature_index => {},
977          genome_checksum => {},          genome_checksum => {},
978          contig_checksum => {},          contig_checksum => {},
# Line 984  Line 1023 
1023      $self->{contig_checksum}->{$genome}->{$contig} = $md5sum;      $self->{contig_checksum}->{$genome}->{$contig} = $md5sum;
1024  }  }
1025    
1026    
1027  sub set_fasta_data  sub set_fasta_data
1028  {  {
1029      my($self, $id, $data) = @_;      my($self, $id, $data) = @_;
# Line 992  Line 1032 
1032  }  }
1033    
1034    
1035    =head2 contigs()
1036    
1037    Add a contig to the list, or return a reference to an array of contigs
1038    
1039    =cut
1040    
1041    sub contigs
1042    {
1043        my($self, $contig) = @_;
1044        $contig && (push @{$self->{contigs}}, $contig);
1045        if (!$self->{contigs} && $self->{contig_length_cache}) {$self->{contigs} = keys %{$self->{contig_length_cache}}}
1046        return $self->{contigs};
1047    }
1048    
1049    =head2 contig_length()
1050    
1051    Get or set the length of a specfic contig.
1052      my $length=$fob->contig_length($contig, $length);
1053      my $length=$fob->contig_length($contig);
1054    
1055    =cut
1056    
1057    sub contig_length
1058    {
1059       my($self, $contig, $length) = @_;
1060       $length && ($self->{contig_length_cache}->{$contig}=$length);
1061       return $self->{contig_length_cache}->{$contig};
1062    }
1063    
1064    =head1 Information about the source of the sequence.
1065    
1066    These are things that we have parsed out the GFF3 file, or want to add into the GFF3 file. We can use these methods to get or set them as required. In general, if a value is supplied that will be used as the new value.
1067    
1068    =cut
1069    
1070    =head2 genome_id()
1071    
1072    Get or set a genome id for this file.
1073    
1074    =cut
1075    
1076    sub genome_id
1077    {
1078        my($self, $genomeid) = @_;
1079        $genomeid && ($self->{genome_id}=$genomeid);
1080        return $self->{genome_id};
1081    }
1082    
1083    =head2 genome_name()
1084    
1085    Get or set a genome id for this file.
1086    
1087    =cut
1088    
1089    sub genome_name
1090    {
1091        my($self, $genomename) = @_;
1092        $genomename && ($self->{genome_name}=$genomename);
1093        return $self->{genome_name};
1094    }
1095    
1096    =head2 project()
1097    
1098    Get or set the project.
1099    
1100    =cut
1101    
1102    sub project
1103    {
1104         my ($self, $pro) = @_;
1105         $pro && ($self->{project}=$pro);
1106         return $self->{project};
1107    }
1108    
1109    =head2 taxonomy()
1110    
1111    Get or set the taxonomy
1112    
1113    =cut
1114    
1115    sub taxonomy
1116    {
1117        my($self, $tax) = @_;
1118        $tax && ($self->{taxonomy}=$tax);
1119        return $self->{taxonomy};
1120    }
1121    
1122    
1123    
1124    
1125    
1126  1;  1;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3