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

View of /FigKernelScripts/find_SEED_SSU_rRNA_genes.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Mon May 4 18:19:57 2009 UTC (11 years, 2 months ago) by golsen
Branch: MAIN
Changes since 1.2: +78 -5 lines
Add command options

# -*- perl -*-
########################################################################
# Copyright (c) 2003-2009 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.
########################################################################

my $usage = <<'End_of_Usage';
Identify the SSU rRNA genes in one or more SEED genomes.

Usage: find_SEED_SSU_rRNA_genes [options] [ genome_id ... ] > found

Output:

    genome_id \t location \t sequence \t tag \t proposed_assignment

Options:

    -a 'role'  #  Proposed assignment; empty string supresses the field
               #    (D = 'SSU rRNA ## 16S rRNA, small subunit ribosomal RNA')
    -b         #  Add a blank line between genomes (D = no blank)
    -c nt      #  Condense the sequence to first and last nt nucleotides (D = full seq)
    -e dist    #  Maximum nucleotides at end to extrapolate a match (D = 10)
    -s         #  Do not show sequence
    -t 'tag'   #  A short tage to identify the nature of the feature; allows
               #    mixing of different types; empty string supresses the field
               #    (D = 'SSU_rRNA')

End_of_Usage

use strict;
use find_homologs;
use gjoseqlib;
use Data::Dumper;
use FIG;
my $fig = new FIG;

my $assignment = 'SSU rRNA ## 16S rRNA, small subunit ribosomal RNA';
my $tag = 'SSU_rRNA';

my $blank       =  0;
my $extrapolate = 10;
my $condense    =  0;

while ( @ARGV && $ARGV[0] =~ s/^-// )
{
    $_ = shift;
    if ( m/^a$/ ) { $assignment  = shift; next }
    if ( s/^c// ) { $condense    = $_ || shift; next }
    if ( s/^e// ) { $extrapolate = $_ || shift; next }
    if ( m/^t$/ ) { $tag         = shift; next }

    if ( s/b//  ) { $blank    = ! $blank }
    if ( m/\S/ )
    {
        print STDERR "Bad flag '$_'\n", $usage;
        exit;
    }
}

use SSU_rRNA_reps;
my @rrna = @SSU_rRNA_reps::SSU_rRNA_reps;

my @genomes = @ARGV;
if ( ! @genomes )
{
    @genomes = grep { $fig->is_prokaryotic($_) } $fig->genomes('complete');
}

my $pat;
$pat = qr/^(.{$condense})....+(.{$condense})$/o if $condense;

foreach my $genome ( @genomes )
{
    my $contig_file = "$FIG_Config::organisms/$genome/contigs";
    -f $contig_file or print STDERR "Could not find contig file $contig_file\n"
                    and exit;

    my $options = { description => 'Small subunit ribosomal RNA',
                    extrapolate =>  10,
                    refseq      => \@rrna
                  };

    my $instances = find_homologs::find_nucleotide_homologs( $contig_file, $options );

    my @instances = map  { $_->[2] }
                    sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }
                    map  { my $loc = $_->{ location };
                           my $seq = $_->{ sequence };
                           my ( $c, $b, $e ) = $loc =~ /^(.*)_(\d+)_(\d+)$/;
                           $seq =~ s/$pat/$1...$2/ if $condense;
                           [ $c, $b+$e, [ $genome, $loc, lc $seq ] ]
                         }
                    @$instances;

    foreach ( @instances )
    {
        print join( "\t", @$_,
                          ( $tag ? $tag : () ),
                          ( $assignment ? $assignment : () )
                  ), "\n"
    }

    print "\n" if @instances && $blank;  #  Blank line between genomes
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3