# Returns nothing.
- my ( $dir, $genome, $fasta_dir, $fh_out, $record, $format, $index );
+ my ( $dir, $genome, $fasta_dir, $phastcons_dir, $vals, $fh_out, $record, $format, $index );
$dir = $options->{ 'dir' } || $ENV{ 'BP_DATA' };
$genome = $options->{ 'genome' };
Maasha::Common::dir_create_if_not_exists( "$dir/genomes" );
Maasha::Common::dir_create_if_not_exists( "$dir/genomes/$genome" );
- if ( -f "$dir/genomes/$genome/fasta/$genome.fna" )
+ if ( grep { $_ =~ /fasta|blast|vmatch/i } @{ $options->{ "formats" } } )
{
- $fasta_dir = "$dir/genomes/$genome/fasta";
- }
- elsif ( grep { $_ =~ /fasta/i } @{ $options->{ "formats" } } )
- {
- Maasha::Common::dir_create_if_not_exists( "$dir/genomes/$genome/fasta" );
+ if ( -f "$dir/genomes/$genome/fasta/$genome.fna" )
+ {
+ $fasta_dir = "$dir/genomes/$genome/fasta";
+ }
+ else
+ {
+ Maasha::Common::dir_create_if_not_exists( "$dir/genomes/$genome/fasta" );
- $fasta_dir = "$dir/genomes/$genome/fasta";
+ $fasta_dir = "$dir/genomes/$genome/fasta";
- $fh_out = Maasha::Common::write_open( "$fasta_dir/$genome.fna" );
+ $fh_out = Maasha::Common::write_open( "$fasta_dir/$genome.fna" );
+ }
}
- else
+ elsif ( grep { $_ =~ /phastcons/i } @{ $options->{ "formats" } } )
{
- $fasta_dir = $BP_TMP;
+ Maasha::Common::dir_create_if_not_exists( "$dir/genomes/$genome/phastcons" );
+
+ $phastcons_dir = "$dir/genomes/$genome/phastcons";
- $fh_out = Maasha::Common::write_open( "$fasta_dir/$genome.fna" );
+ $fh_out = Maasha::Common::write_open( "$phastcons_dir/$genome.pp" );
}
while ( $record = get_record( $in ) )
{
- if ( $fh_out and $record->{ "SEQ_NAME" } and $record->{ "SEQ" } ) {
+ if ( $fh_out and $record->{ "SEQ_NAME" } and $record->{ "SEQ" } )
+ {
Maasha::Fasta::put_entry( [ $record->{ "SEQ_NAME" }, $record->{ "SEQ" } ], $fh_out, $options->{ "wrap" } );
}
+ elsif ( $fh_out and $record->{ "CHR" } and $record->{ "CHR_BEG" } and $record->{ "STEP" } and $record->{ "VALS" } )
+ {
+ print $fh_out "fixedStep chrom=$record->{ 'CHR' } start=$record->{ 'CHR_BEG' } step=$record->{ 'STEP' }\n";
+
+ $vals = $record->{ 'VALS' };
+
+ $vals =~ tr/,/\n/;
+
+ print $fh_out "$vals\n";
+ }
put_record( $record, $out ) if not $options->{ "no_stream" };
}
foreach $format ( @{ $options->{ 'formats' } } )
{
- if ( $format =~ /^fasta$/i ) { Maasha::Fasta::fasta_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/fasta/$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 =~ /^vmatch$/i ) { Maasha::Match::vmatch_index( "$genome.fna", $fasta_dir, "$dir/genomes/$genome/vmatch", $BP_TMP ) }
+ if ( $format =~ /^fasta$/i ) { Maasha::Fasta::fasta_index( "$fasta_dir/$genome.fna", "$dir/genomes/$genome/fasta/$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 =~ /^vmatch$/i ) { Maasha::Match::vmatch_index( "$genome.fna", $fasta_dir, "$dir/genomes/$genome/vmatch", $BP_TMP ) }
+ elsif ( $format =~ /^phastcons$/i ) { Maasha::UCSC::phastcons_index( "$genome.pp", $phastcons_dir ) }
}
close $fh_out if $fh_out;