« blib/lib/Bio/AutomatedAnnotation/ParseGenesFromGFF.pm
↑ Summary
blib/lib/Bio/AutomatedAnnotation.pm »
| 1 | package Bio::AutomatedAnnotation::CommandLine::ParseGenesFromGFFs; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: provide a commandline interface to pull out genes from multiple GFF files | ||||||||||
| 4 | |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Getopt::Long qw(GetOptionsFromArray); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Bio::AutomatedAnnotation::ParseGenesFromGFFs; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 ); | |||||||||
| 11 | 1 | has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 12 | 1 | has 'help' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||
| 13 | |||||||||||
| 14 | 1 | has 'amino_acids' => ( is => 'rw', isa => 'Bool', default => 0); | |||||||||
| 15 | 1 | has 'gff_files' => ( is => 'rw', isa => 'ArrayRef' ); | |||||||||
| 16 | 1 | has 'search_query' => ( is => 'rw', isa => 'Str' ); | |||||||||
| 17 | 5 | ▶ | has 'search_qualifiers' => ( is => 'rw', isa => 'ArrayRef', default => sub { ['gene'] } ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | has 'output_filename' => ( is => 'rw', isa => 'Str' ); | |||||||||
| 19 | |||||||||||
| 20 | 1 | has '_error_message' => ( is => 'rw', isa => 'Str' ); | |||||||||
| 21 | |||||||||||
| 22 | sub BUILD { | ||||||||||
| 23 | 5 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
BUILD: called CC=8 SCAR=21.5
Pod
undocumented
| |||||||||||
| 24 | |||||||||||
| 25 | my ( | ||||||||||
| 26 | 5 | $nucleotides, $gff_files, $search_query, $search_qualifiers, $output_filename, $help | |||||||||
| 27 | ); | ||||||||||
| 28 | |||||||||||
| 29 | 5 | GetOptionsFromArray( | |||||||||
| 30 | $self->args, | ||||||||||
| 31 | 'g|gene=s' => \$search_query, | ||||||||||
| 32 | 'p|search_products' => \$search_qualifiers, | ||||||||||
| 33 | 'o|output=s' => \$output_filename, | ||||||||||
| 34 | 'n|nucleotides' => \$nucleotides, | ||||||||||
| 35 | 'h|help' => \$help, | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | 5 | ▶ | if(defined($nucleotides)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | { | ||||||||||
| 40 | 3 | $self->amino_acids(0); | |||||||||
| 41 | } | ||||||||||
| 42 | else | ||||||||||
| 43 | { | ||||||||||
| 44 | 2 | $self->amino_acids(1); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 5 | ▶ | if(defined($search_query)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | { | ||||||||||
| 49 | 5 | $self->search_query($search_query); | |||||||||
| 50 | } | ||||||||||
| 51 | else | ||||||||||
| 52 | { | ||||||||||
| 53 | 0 | $self->_error_message("Error: You must provide a gene to search for"); | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 5 | ▶ | $self->output_filename($output_filename) if(defined($output_filename)); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 5 | ▶ | push(@{$self->search_qualifiers}, 'product') if(defined($search_qualifiers)); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | 5 | ▶ | if(@{$self->args} == 0) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | { | ||||||||||
| 61 | 0 | $self->_error_message("Error: You need to provide at least 1 GFF file"); | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 5 | for my $filename (@{$self->args}) | |||||||||
| 65 | { | ||||||||||
| 66 | 8 | ▶ | if(! -e $filename) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | { | ||||||||||
| 68 | 0 | $self->_error_message("Error: Cant access file $filename"); | |||||||||
| 69 | 0 | last; | |||||||||
| 70 | } | ||||||||||
| 71 | } | ||||||||||
| 72 | 5 | $self->gff_files($self->args); | |||||||||
| 73 | |||||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | sub run { | ||||||||||
| 77 | 5 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
run: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||
| 78 | |||||||||||
| 79 | 5 | ▶ | ( !$self->help ) or die $self->usage_text; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | 5 | ▶ | if(defined($self->_error_message)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | { | ||||||||||
| 82 | 0 | print $self->_error_message."\n"; | |||||||||
| 83 | 0 | die $self->usage_text; | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | 5 | my %input_params = (gff_files => $self->gff_files, | |||||||||
| 87 | search_query => $self->search_query, | ||||||||||
| 88 | search_qualifiers => $self->search_qualifiers, | ||||||||||
| 89 | amino_acids => $self->amino_acids); | ||||||||||
| 90 | |||||||||||
| 91 | 5 | ▶ | if(defined($self->output_filename)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | { | ||||||||||
| 93 | 1 | $input_params{output_file} = $self->output_filename; | |||||||||
| 94 | } | ||||||||||
| 95 | |||||||||||
| 96 | 5 | my $gene_finder = Bio::AutomatedAnnotation::ParseGenesFromGFFs->new( | |||||||||
| 97 | \%input_params | ||||||||||
| 98 | ); | ||||||||||
| 99 | |||||||||||
| 100 | 5 | $gene_finder->create_fasta_file; | |||||||||
| 101 | |||||||||||
| 102 | 5 | print "Samples containing gene:\t".$gene_finder->files_with_hits()."\n"; | |||||||||
| 103 | 5 | print "Samples missing gene:\t".$gene_finder->files_without_hits()."\n"; | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | sub usage_text { | ||||||||||
| 107 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
usage_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 108 | |||||||||||
| 109 | 0 | return <<USAGE; | |||||||||
| 110 | Usage: parse_genes_from_gffs [options] | ||||||||||
| 111 | Parse Genes from GFF files into a Fasta file | ||||||||||
| 112 | |||||||||||
| 113 | # Get the protein sequence for the 'gryA' gene from two GFF files | ||||||||||
| 114 | parse_genes_from_gffs -g gryA example1.gff example2.gff | ||||||||||
| 115 | |||||||||||
| 116 | # Get the protein sequence for the 'gryA' gene from loads of GFF files | ||||||||||
| 117 | parse_genes_from_gffs -g gryA *.gff | ||||||||||
| 118 | |||||||||||
| 119 | # Expand the search to include the information in the product field | ||||||||||
| 120 | parse_genes_from_gffs -g gryA -p example1.gff example2.gff | ||||||||||
| 121 | |||||||||||
| 122 | # Output the nucleotide sequence to the FASTA file | ||||||||||
| 123 | parse_genes_from_gffs -g gryA -n example1.gff example2.gff | ||||||||||
| 124 | |||||||||||
| 125 | # Provide an output filename | ||||||||||
| 126 | parse_genes_from_gffs -g gryA -o outputfile.fa example1.gff example2.gff | ||||||||||
| 127 | |||||||||||
| 128 | # This help message | ||||||||||
| 129 | parse_genes_from_gffs -h | ||||||||||
| 130 | |||||||||||
| 131 | USAGE | ||||||||||
| 132 | } | ||||||||||
| 133 | |||||||||||
| 134 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 135 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 136 | 1 | 1; | |||||||||
| 137 | |||||||||||
| 138 | __END__ | ||||||||||
| 139 | |||||||||||
| 140 | =pod | ||||||||||
| 141 | |||||||||||
| 142 | =encoding UTF-8 | ||||||||||
| 143 | |||||||||||
| 144 | =head1 NAME | ||||||||||
| 145 | |||||||||||
| 146 | Bio::AutomatedAnnotation::CommandLine::ParseGenesFromGFFs - provide a commandline interface to pull out genes from multiple GFF files | ||||||||||
| 147 | |||||||||||
| 148 | =head1 VERSION | ||||||||||
| 149 | |||||||||||
| 150 | version 1.182685 | ||||||||||
| 151 | |||||||||||
| 152 | =head1 SYNOPSIS | ||||||||||
| 153 | |||||||||||
| 154 | provide a commandline interface to pull out genes from multiple GFF files | ||||||||||
| 155 | |||||||||||
| 156 | =head1 AUTHOR | ||||||||||
| 157 | |||||||||||
| 158 | Andrew J. Page <ap13@sanger.ac.uk> | ||||||||||
| 159 | |||||||||||
| 160 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 161 | |||||||||||
| 162 | This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. | ||||||||||
| 163 | |||||||||||
| 164 | This is free software, licensed under: | ||||||||||
| 165 | |||||||||||
| 166 | The GNU General Public License, Version 3, June 2007 | ||||||||||
| 167 | |||||||||||
| 168 | =cut | ||||||||||