Skip to content

Commit

Permalink
Add parsing of FAI file for refSeqs in GenomeDB
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 11, 2018
1 parent c85375c commit 03bd658
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/perl5/Bio/JBrowse/Cmd/IndexNames.pm
Expand Up @@ -18,6 +18,7 @@ use Storable ();
use File::Path ();
use File::Temp ();
use List::Util ();
use Data::Dumper;

use GenomeDB ();
use Bio::GFF3::LowLevel qw/gff3_parse_feature/;
Expand Down
32 changes: 31 additions & 1 deletion src/perl5/GenomeDB.pm
Expand Up @@ -257,7 +257,37 @@ Returns a arrayref of hashrefs defining the reference sequences, as:
=cut

sub refSeqs {
shift->{rootStore}->get( 'seq/refSeqs.json', [] );
my $self = shift;
my $conf = Bio::JBrowse::ConfigurationManager->new( conf => {
baseUrl => "$self->{dataDir}",
include => [ $trackListPath, 'tracks.conf' ],
})->get_final_config;

if(my $seqs = $conf->{refSeqs}) {
if($seqs =~ /.fai$/) {
my @refs;
my $file = File::Spec->join($self->{dataDir}, $seqs);
open FAI, "<$file" or die "Unable to read from $file $!\n";
while (<FAI>) {
if (/([^\t]+)\t(\d+)\t(\d+)\t(\d+)\t(\d+)/) {
push(@refs, {
name => $1,
start => 0,
end => $2+0,
offset => $3,
line_length => $4,
line_byte_length => $5
});
} else {
die "Improperly-formatted line in fai file ($file):\n$_\n"
}
}
close FAI;
return \@refs;
}
} else {
return $self->{rootStore}->get( 'seq/refSeqs.json', [] );
}
}


Expand Down

0 comments on commit 03bd658

Please sign in to comment.