X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bp_bin%2Fformat_genome;h=9b3e4fe81790b7ea159efaad477bb5d87922dbad;hb=5de6112b70b59420b245ce636a8b2e3c90acbe00;hp=5e5b8def63955ed0ed6fc0885ced964f4fa2c92b;hpb=9854397f83abe8d5a8c614b799ef3107d3f85f80;p=biopieces.git diff --git a/bp_bin/format_genome b/bp_bin/format_genome index 5e5b8de..9b3e4fe 100755 --- a/bp_bin/format_genome +++ b/bp_bin/format_genome @@ -1,4 +1,4 @@ -#!/usr/bin/env perl -w +#!/usr/bin/env perl # Copyright (C) 2007-2009 Martin A. Hansen. @@ -26,20 +26,26 @@ # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +use warnings; use strict; use Maasha::Fasta; use Maasha::Biopieces; +use Maasha::Bowtie; +use Maasha::BWA; +use Maasha::NCBI; +use Maasha::Match; +use Maasha::UCSC; # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -my ( $run_time_beg, $run_time_end, $default, $formats, $options, $in, $out, $record, $data_out, $entry, +my ( $default, $formats, $options, $in, $out, $record, $data_out, $entry, $genome, $dir, $fasta_dir, $phastcons_dir, $fh_out, $vals, $format, $tmp_dir ); $tmp_dir = Maasha::Biopieces::get_tmpdir(); $default = $ENV{ 'BP_DATA' }; -$formats = 'fasta,blast,vmatch,phastcons'; +$formats = 'fasta,blast,vmatch,bowtie,bwa,phastcons'; $options = Maasha::Biopieces::parse_options( [ @@ -59,7 +65,7 @@ $genome = $options->{ 'genome' }; Maasha::Filesys::dir_create_if_not_exists( "$dir/genomes" ); Maasha::Filesys::dir_create_if_not_exists( "$dir/genomes/$genome" ); -if ( grep { $_ =~ /fasta|blast|vmatch/i } @{ $options->{ "formats" } } ) +if ( grep { $_ =~ /fasta|blast|vmatch|bowtie|bwa/i } @{ $options->{ "formats" } } ) { if ( -f "$dir/genomes/$genome/fasta/$genome.fna" ) { @@ -89,7 +95,7 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) { Maasha::Fasta::put_entry( $entry, $fh_out ); } - elsif ( $fh_out and $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "STEP" } and $record->{ "VALS" } ) + elsif ( $fh_out and $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "STEP" } and $record->{ "VALS" } ) # TODO: clean this! { print $fh_out "fixedStep chrom=$record->{ 'CHR' } start=$record->{ 'CHR_BEG' } step=$record->{ 'STEP' }\n"; @@ -103,16 +109,25 @@ while ( $record = Maasha::Biopieces::get_record( $in ) ) Maasha::Biopieces::put_record( $record, $out ) if not $options->{ "no_stream" }; } +close $fh_out if $fh_out; + foreach $format ( @{ $options->{ 'formats' } } ) { - if ( $format =~ /^fasta$/i ) { Maasha::Fasta::fasta_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/fasta/$genome.index" ) } + print STDERR qq(Creating format: $format for $genome ... ) if $options->{ 'verbose' }; + + if ( $format =~ /^fasta$/i ) { Maasha::Fasta::fasta_index( "$fasta_dir/$genome.fna", $fasta_dir, "$genome.index" ) } elsif ( $format =~ /^blast$/i ) { Maasha::NCBI::blast_index( "$genome.fna", $fasta_dir, "$dir/genomes/$genome/blast", "dna", $genome ) } - elsif ( $format =~ /^blat$/i ) { print STDERR "BLAT FORMAT NOT IMPLEMENTED" } + elsif ( $format =~ /^blat$/i ) { warn "BLAT FORMAT NOT IMPLEMENTED\n" } elsif ( $format =~ /^vmatch$/i ) { Maasha::Match::vmatch_index( "$genome.fna", $fasta_dir, "$dir/genomes/$genome/vmatch", $tmp_dir ) } + elsif ( $format =~ /^bowtie$/i ) { Maasha::Bowtie::bowtie_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/bowtie", $genome, $options->{ 'verbose' } ) } + elsif ( $format =~ /^bwa$/i ) { Maasha::BWA::bwa_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/bwa", $genome, $options->{ 'verbose' } ) } elsif ( $format =~ /^phastcons$/i ) { Maasha::UCSC::phastcons_index( "$genome.pp", $phastcons_dir ) } + + print STDERR qq(done.\n) if $options->{ 'verbose' }; } -close $fh_out if $fh_out; +Maasha::Biopieces::close_stream( $in ); +Maasha::Biopieces::close_stream( $out ); # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @@ -120,19 +135,13 @@ close $fh_out if $fh_out; BEGIN { - $run_time_beg = Maasha::Biopieces::run_time(); - - Maasha::Biopieces::log_biopiece(); + Maasha::Biopieces::status_set(); } + END { - Maasha::Biopieces::close_stream( $in ); - Maasha::Biopieces::close_stream( $out ); - - $run_time_end = Maasha::Biopieces::run_time(); - - Maasha::Biopieces::run_time_print( $run_time_beg, $run_time_end, $options ); + Maasha::Biopieces::status_log(); }