[Bio] / FigKernelScripts / find_SEED_SSU_rRNA_genes.pl Repository:
ViewVC logotype

Diff of /FigKernelScripts/find_SEED_SSU_rRNA_genes.pl

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

revision 1.2, Sat Feb 21 15:37:22 2009 UTC revision 1.3, Mon May 4 18:19:57 2009 UTC
# Line 1  Line 1 
1  #! /usr/bin/perl  # -*- perl -*-
2    ########################################################################
3    # Copyright (c) 2003-2009 University of Chicago and Fellowship
4    # for Interpretations of Genomes. All Rights Reserved.
5  #  #
6  #   find_SEED_SSU_rRNA_genes [ genome_id ... ]  # This file is part of the SEED Toolkit.
7  #  #
8    # The SEED Toolkit is free software. You can redistribute
9    # it and/or modify it under the terms of the SEED Toolkit
10    # Public License.
11    #
12    # You should have received a copy of the SEED Toolkit Public License
13    # along with this program; if not write to the University of Chicago
14    # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15    # Genomes at veronika@thefig.info or download a copy from
16    # http://www.theseed.org/LICENSE.TXT.
17    ########################################################################
18    
19    my $usage = <<'End_of_Usage';
20    Identify the SSU rRNA genes in one or more SEED genomes.
21    
22    Usage: find_SEED_SSU_rRNA_genes [options] [ genome_id ... ] > found
23    
24    Output:
25    
26        genome_id \t location \t sequence \t tag \t proposed_assignment
27    
28    Options:
29    
30        -a 'role'  #  Proposed assignment; empty string supresses the field
31                   #    (D = 'SSU rRNA ## 16S rRNA, small subunit ribosomal RNA')
32        -b         #  Add a blank line between genomes (D = no blank)
33        -c nt      #  Condense the sequence to first and last nt nucleotides (D = full seq)
34        -e dist    #  Maximum nucleotides at end to extrapolate a match (D = 10)
35        -s         #  Do not show sequence
36        -t 'tag'   #  A short tage to identify the nature of the feature; allows
37                   #    mixing of different types; empty string supresses the field
38                   #    (D = 'SSU_rRNA')
39    
40    End_of_Usage
41    
42  use strict;  use strict;
43  use find_homologs;  use find_homologs;
# Line 10  Line 46 
46  use FIG;  use FIG;
47  my $fig = new FIG;  my $fig = new FIG;
48    
49    my $assignment = 'SSU rRNA ## 16S rRNA, small subunit ribosomal RNA';
50    my $tag = 'SSU_rRNA';
51    
52    my $blank       =  0;
53    my $extrapolate = 10;
54    my $condense    =  0;
55    
56    while ( @ARGV && $ARGV[0] =~ s/^-// )
57    {
58        $_ = shift;
59        if ( m/^a$/ ) { $assignment  = shift; next }
60        if ( s/^c// ) { $condense    = $_ || shift; next }
61        if ( s/^e// ) { $extrapolate = $_ || shift; next }
62        if ( m/^t$/ ) { $tag         = shift; next }
63    
64        if ( s/b//  ) { $blank    = ! $blank }
65        if ( m/\S/ )
66        {
67            print STDERR "Bad flag '$_'\n", $usage;
68            exit;
69        }
70    }
71    
72  use SSU_rRNA_reps;  use SSU_rRNA_reps;
73  my @rrna = @SSU_rRNA_reps::SSU_rRNA_reps;  my @rrna = @SSU_rRNA_reps::SSU_rRNA_reps;
74    
# Line 19  Line 78 
78      @genomes = grep { $fig->is_prokaryotic($_) } $fig->genomes('complete');      @genomes = grep { $fig->is_prokaryotic($_) } $fig->genomes('complete');
79  }  }
80    
81    my $pat;
82    $pat = qr/^(.{$condense})....+(.{$condense})$/o if $condense;
83    
84  foreach my $genome ( @genomes )  foreach my $genome ( @genomes )
85  {  {
86      my $contig_file = "$FIG_Config::organisms/$genome/contigs";      my $contig_file = "$FIG_Config::organisms/$genome/contigs";
87      -f $contig_file or print STDERR "Could not find contig file $contig_file\n"      -f $contig_file or print STDERR "Could not find contig file $contig_file\n"
88                      and exit;                      and exit;
89    
90      my $options = { description => 'Small subunit ribosomal RNA',      my $options = { description => 'Small subunit ribosomal RNA',
91                      extrapolate =>  10,                      extrapolate =>  10,
92                      refseq      => \@rrna                      refseq      => \@rrna
93                    };                    };
94    
95      my $instances = find_homologs::find_nucleotide_homologs( $contig_file, $options );      my $instances = find_homologs::find_nucleotide_homologs( $contig_file, $options );
96    
97      my @instances = map  { $_->[2] }      my @instances = map  { $_->[2] }
98                      sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }                      sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }
99                      map  { my $loc = $_->{ location };                      map  { my $loc = $_->{ location };
100                             my $seq = $_->{ sequence };                             my $seq = $_->{ sequence };
101                             my ( $c, $b, $e ) = $loc =~ /^(.*)_(\d+)_(\d+)$/;                             my ( $c, $b, $e ) = $loc =~ /^(.*)_(\d+)_(\d+)$/;
102                             $seq =~ s/^(.{24})...+(.{24})$/$1...$2/;                             $seq =~ s/$pat/$1...$2/ if $condense;
103                             [ $c, $b+$e, [ $genome, $loc, lc $seq ] ]                             [ $c, $b+$e, [ $genome, $loc, lc $seq ] ]
104                           }                           }
105                      @$instances;                      @$instances;
106      foreach ( @instances ) { print join( "\t", @$_ ), "\n" }  
107      print "\n" if @instances;      foreach ( @instances )
108        {
109            print join( "\t", @$_,
110                              ( $tag ? $tag : () ),
111                              ( $assignment ? $assignment : () )
112                      ), "\n"
113        }
114    
115        print "\n" if @instances && $blank;  #  Blank line between genomes
116  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3