Commit aeb6dd59 authored by Gautier Koscielny's avatar Gautier Koscielny
Browse files

Option output_file|o added to store the GFF output stream in a specific file.

parent 672ce2c5
......@@ -30,7 +30,7 @@
=head1 SYNOPSIS
Fetch_gff.pl -dbhost host -dbuser ensro -dbname homo_sapiens_core_57_37b
Fetch_gff.pl -dbhost host -dbuser ensro -dbname homo_sapiens_core_58_37c -output_file homo_sapiens_core_58_37c_variants.gff
=head1 DESCRIPTION
......@@ -39,7 +39,7 @@ from an Ensembl core database.
here is an example commandline
./Fetch_gff.pl -dbhost host -dbuser user -dbname my_db -dbpass ****
./Fetch_gff.pl -dbhost host -dbuser user -dbname my_db -dbpass **** -output_file transcript_variants.gff
=head1 OPTIONS
......@@ -48,6 +48,7 @@ here is an example commandline
-dbuser what username to connect as (dbuser= in locator)
-dbpass what password to use (dbpass= in locator)
-chr which chromosome (optional)
-output_file|-o where the GFF output is written (optional, STDOUT by default)
-help displays this documentation with PERLDOC
=cut
......@@ -71,6 +72,7 @@ use Bio::EnsEMBL::Utils::Exception qw(throw warning);
my $dbuser = '';
my $dbpass = '';
my $chr = undef;
my $output_file = undef;
my $help;
my @coord_system;
......@@ -79,22 +81,36 @@ use Bio::EnsEMBL::Utils::Exception qw(throw warning);
'dbport:n' => \$port,
'dbname:s' => \$dbname,
'dbuser:s' => \$dbuser,
'chr:s' => \$chr,
'dbpass:s' => \$dbpass,
'chr:s' => \$chr,
'output_file|o=s' => \$output_file,
'h|help' => \$help,
) or ($help = 1);
if(!$host || !$dbuser || !$dbname || !$dbpass){
if(!$host || !$dbuser || !$dbname){
print STDERR "Can't get any information without database details\n";
print STDERR "-dbhost $host -dbuser $dbuser -dbname $dbname ".
" -dbpass $dbpass\n";
print STDERR "-dbhost '$host' -dbuser '$dbuser' -dbname '$dbname' ".
" -dbpass '$dbpass'\n";
$help = 1;
}
}
if ($help) {
exec('perldoc', $0);
}
my $output_stream;
if (defined($output_file)) {
open ($output_stream, ">$output_file") || throw "Can't open '$output_file' file for writing\n";
} else {
$output_stream = \*STDOUT;
print STDERR "Will write GFF stream to the standard output.\n";
}
my $db = Bio::EnsEMBL::DBSQL::DBAdaptor->new
(-dbname => $dbname,
-host => $host,
......@@ -149,10 +165,9 @@ use Bio::EnsEMBL::Utils::Exception qw(throw warning);
my $slice = $exon->slice->seq_region_name();
$exon_std =~ s/-1/-/ ;
$exon_std =~ s/1/+/ ;
print "$chr\tEnsembl\texon\t$exon_start\t$exon_end\t.\t$exon_std\t.\tgene_id \"$gene_id\"; transcript_id \"$transcr_id\"; exon_id \"$exon_id\"\n" ;
print $output_stream "$chr\tEnsembl\texon\t$exon_start\t$exon_end\t.\t$exon_std\t.\tgene_id \"$gene_id\"; transcript_id \"$transcr_id\"; exon_id \"$exon_id\"\n" ;
}
}
}
exit 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment