Skip to content

Commit

Permalink
add --chunksize arg to prepare-refseqs
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuels committed Aug 23, 2012
1 parent 6fff28e commit 21457f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions bin/prepare-refseqs.pl
Expand Up @@ -61,6 +61,12 @@ =head1 OPTIONS
chunks be .txt.gz. NOTE: this requires a bit of additional web server
configuration to be served correctly.
=item --chunksize <num>
Size of sequence chunks to make, in base pairs. Default 20kb. This
is multiplied by 4 if --compress is passed, so that the compressed
sequence files are still approximately this size.
=back
=head1 AUTHOR
Expand Down
11 changes: 6 additions & 5 deletions src/perl5/Bio/JBrowse/Cmd/FormatSequences.pm
Expand Up @@ -22,23 +22,23 @@ use JsonGenerator;
use FastaDatabase;

sub option_defaults {(
out => 'data'
out => 'data',
chunksize => 20_000
)}

sub option_definitions {(
"out=s",
"conf=s",
"noseq",
"gff=s",
"chunksize=s",
"fasta=s@",
"refs=s",
"refids=s",
"compress",
"help|h|?",
)}

my $chunkSize = 20000;

sub run {
my ( $self ) = @_;
my $seqTrackName = "DNA";
Expand All @@ -49,6 +49,7 @@ sub run {
pod2usage( 'must provide either a --fasta, --gff, or --conf option' )
unless defined $self->opt('gff') || $self->opt('conf') || $self->opt('fasta');

my $chunkSize = $self->opt('chunksize');
$chunkSize *= 4 if $compress;

# $seqRel is the path relative to --out
Expand Down Expand Up @@ -246,15 +247,15 @@ sub refName {
}

sub exportSeqChunks {
my ( $self, $dir, $compress, $len, $db, $segDef, $start, $end ) = @_;
my ( $self, $dir, $compress, $chunkSize, $db, $segDef, $start, $end ) = @_;

mkdir $dir unless -d $dir;
$start = 1 if $start < 1;
$db->absolute( 1 ) if $db->can('absolute');

my $chunkStart = $start;
while( $chunkStart <= $end ) {
my $chunkEnd = $chunkStart + $len - 1;
my $chunkEnd = $chunkStart + $chunkSize - 1;
my $chunkNum = floor( ($chunkStart - 1) / $chunkSize );
my ($seg) = $db->segment( @$segDef,
-start => $chunkStart,
Expand Down

0 comments on commit 21457f4

Please sign in to comment.