Skip to content

Commit

Permalink
Merge pull request #25 from Rfam/rfam-13
Browse files Browse the repository at this point in the history
Updates for Rfam 13
  • Loading branch information
AntonPetrov authored Sep 27, 2017
2 parents 7f9dc64 + c8a8232 commit 1ade845
Show file tree
Hide file tree
Showing 94 changed files with 531,127 additions and 502 deletions.
4 changes: 3 additions & 1 deletion PfamBase/root/components/wrapper.tt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ELSE;
PROCESS components/head.tt -%]
</head>

<body>
<body ng-app="rfamApp" id="ng-app">

[%# add an Iframe for use by the history manager. Only required for IE,
# hence the conditional comments. The input is required for all browsers -%]
Expand All @@ -55,7 +55,9 @@ ELSE;

[% # add the common footer %]
<!-- start of footer -->
[% IF pageType != 'genome' && pageType != 'accession' -%]
<div id="footer"></div>
[% END; %]

<div class="cleaner"><!-- wrap --></div>
<!-- end of footer -->
Expand Down
4 changes: 3 additions & 1 deletion PfamBase/root/pages/layout.tt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ END; # of "FOREACH block"
#--------------------------------------
# add the icons

PROCESS components/icons.tt;
IF pageType != 'search' AND pageType != 'genome' AND pageType != 'accession';
PROCESS components/icons.tt;
END;

#--------------------------------------
# and construct the page from the components that we've assembled
Expand Down
71 changes: 71 additions & 0 deletions RfamWeb/lib/RfamWeb/Controller/Accession.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package RfamWeb::Controller::Accession;

use Moose;
use namespace::autoclean;

BEGIN {
extends 'Catalyst::Controller';
}

# set the name of the section
__PACKAGE__->config( SECTION => 'accession' );

#-------------------------------------------------------------------------------

=head1 METHODS
=head2 rna
=cut

sub accession : Chained( '/' )
PathPart( 'accession' )
CaptureArgs( 1 ) {
my ( $this, $c, $tainted_entry ) = @_;

my ( $entry ) = $tainted_entry =~ m/^([A-Za-z0-9\.]+)$/;
unless ( defined $entry ) {
$c->log->debug( 'Sequence summary: no valid accession found' )
if $c->debug;
$c->stash->{errorMsg} = 'No valid accession';
return;
}

my $seq_start = $c->request->query_parameters->{seq_start};
unless ( defined $seq_start ) {
$c->log->debug( 'Sequence summary: no seq_start found' )
if $c->debug;
$c->stash->{errorMsg} = 'No sequence start specified';
return;
}

my $seq_end = $c->request->query_parameters->{seq_end};
unless ( defined $seq_end ) {
$c->log->debug( 'Sequence summary: no seq_end found' )
if $c->debug;
$c->stash->{errorMsg} = 'No sequence end specified';
return;
}

$c->stash->{entry} = $entry;
$c->stash->{seq_start} = $seq_start;
$c->stash->{seq_end} = $seq_end;
$c->stash->{pageType} = 'accession';
$c->stash->{template} = 'pages/tabless-layout.tt';
}

#-------------------------------------------------------------------------------

=head2 rna_page
=cut

sub accession_page : Chained( 'accession' )
PathPart( '' )
Args( 0 ) {
my ( $this, $c ) = @_;

$c->cache_page( 604800 );
}
2 changes: 1 addition & 1 deletion RfamWeb/lib/RfamWeb/Controller/Family.pm
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ sub get_summary_data : Private {
my $summaryData = {};

# number of sequences in full alignment
$summaryData->{numSequences} = $c->stash->{rfam}->num_full;
$summaryData->{numSequences} = $c->stash->{rfam}->num_full + $c->stash->{rfam}->num_seed;

# number of structures known for the domain
my $rs = $c->model('RfamDB::PdbFullRegion')->search( { rfam_acc => $c->stash->{acc}, is_significant => 1 },{});
Expand Down
100 changes: 31 additions & 69 deletions RfamWeb/lib/RfamWeb/Controller/Genome.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ __PACKAGE__->config( SECTION => 'genome' );
=head2 genome
The start of a chain for genomes. Tries to process its argument as an NCBI
The start of a chain for genomes. Tries to process its argument as an NCBI
taxonomy id.
=cut
Expand All @@ -50,7 +50,7 @@ sub genome : Chained( '/' )
PathPart( 'genome' )
CaptureArgs( 1 ) {
my ( $this, $c, $tainted_entry ) = @_;

$c->log->debug( 'Genome::genome: start of "genome" chain' )
if $c->debug;

Expand All @@ -63,25 +63,11 @@ sub genome : Chained( '/' )

return;
}
$c->log->debug( "Genome::genome: looking for genome entry '$entry'" )
if $c->debug;

$c->stash->{entry} = $entry;
$c->stash->{pageType} = 'genome';
$c->stash->{template} = 'pages/tabless-layout.tt';

# get the basic genome and chromosome information
$c->forward( 'get_chromosomes' );
unless ( $c->stash->{chromosomes} ) {
$c->log->debug( 'Genome::genome: no chromosomes found' )
if $c->debug;

$c->stash->{errorMsg} = 'No chromosomes found for that genome identifier';

return;
}

$c->forward( 'get_genome_data' ); # need the chromosome data before we can
# be sure to get genome data, because we
# use the ncbi_id to retrieve it
}

#-------------------------------------------------------------------------------
Expand All @@ -99,49 +85,25 @@ sub genome_page : Chained( 'genome' )
my ( $this, $c ) = @_;

$c->cache_page( 604800 );

$c->log->debug( 'Genome::genome_page: building a "genome" page' )
if $c->debug;

# retrieve extra data for the genome that will be used by the template
$c->forward( 'get_regions' );

#----------------------------------------

unless ( $c->stash->{output_xml} ) {
$c->log->debug( 'Genome::get_data: NOT returning XML; adding extra info' )
if $c->debug;

# if this request originates at the top level of the object hierarchy,
# i.e. if it's a call on the "default" method of the Family object,
# then we'll need to do a few extra things
if ( ref $this eq 'RfamWeb::Controller::Genome' ) {
$c->log->debug( 'Genome::genome_page: adding genome summary info' ) if $c->debug;

$c->forward( 'get_summary_data' );
}

} # end of "unless XML..."

}

#-------------------------------------------------------------------------------

=head2 gff
Treats its argument as an auto_genome number and uses it to retrieve the GFF for
the specified genome segment. Chained to "genome".
Treats its argument as an auto_genome number and uses it to retrieve the GFF for
the specified genome segment. Chained to "genome".
=cut

sub gff : Chained( 'genome' )
PathPart( 'gff' )
Args( 1 ) {
my ( $this, $c, $tainted_ag ) = @_;

$c->log->debug( 'Genome::gff: retrieving a GFF file' )
if $c->debug;

my ( $ag ) = $tainted_ag =~ m/^(\w+)$/;
unless ( defined $ag ) {
$c->log->debug( 'Genome::gff: no valid auto_genome found' )
Expand All @@ -155,7 +117,7 @@ sub gff : Chained( 'genome' )
my $rs = $c->model('RfamDB::GenomeGff')
->search( { 'me.auto_genome' => $ag },
{ join => [ 'auto_genome' ] } );

unless ( defined $rs ) {
$c->log->debug( 'Genome::gff: no GFF found auto_genome for that segment' )
if $c->debug;
Expand All @@ -166,20 +128,20 @@ sub gff : Chained( 'genome' )
}

my $gff = Compress::Zlib::memGunzip( $rs->first->gff3 );

my $filename;
my $ge = $rs->first->auto_genome;
if ( defined $ge->genome_acc ) {
$filename = $ge->genome_acc . '.gff';
$c->log->debug( "Genome::gff: using 'genome_acc' for filename: |$filename|" )
if $c->debug;
}
else {
else {
$filename = $ge->ensembl_id . '.gff';
$c->log->debug( "Genome::gff: using 'ensembl_id' for filename: |$filename|" )
if $c->debug;
}

$c->res->content_type( 'text/plain' );
$c->res->header( 'Content-disposition' => "attachment; filename=$filename" );
$c->res->body( $gff );
Expand All @@ -189,16 +151,16 @@ sub gff : Chained( 'genome' )

=head2 all_gffs
Returns the concatenated contents of all of the available GFF files for this
genome. Chained to "genome".
Returns the concatenated contents of all of the available GFF files for this
genome. Chained to "genome".
=cut

#sub all_gffs : Chained( 'genome' )
# PathPart( 'gff' )
# Args( 0 ) {
# my ( $this, $c ) = @_;
#
#
# $c->log->debug( 'Genome::genome_page: retrieving all GFF files for this genome' )
# if $c->debug;
#
Expand All @@ -211,22 +173,22 @@ genome. Chained to "genome".
# push @ags, $ag;
# }
#
# $c->log->debug( 'Genome::all_gffs: auto_genomes which have hits: |'
# $c->log->debug( 'Genome::all_gffs: auto_genomes which have hits: |'
# . join( ', ', @ags ) . '|' )
# if $c->debug;
#
# my @gffs = $c->model('RfamDB::GenomeGff')
# ->search( { auto_genome => { 'IN', \@ags } },
# { order_by => [ 'auto_genome' ] } );
#
# $c->log->debug( 'Genome::all_gffs: found |' . scalar @gffs . '| GFF files' )
# $c->log->debug( 'Genome::all_gffs: found |' . scalar @gffs . '| GFF files' )
# if $c->debug;
#
#
# foreach my $gff ( @gffs ) {
# $c->log->debug( 'Genome::all_gffs: gff auto_genome:|' . $gff->auto_genome . '|' )
# $c->log->debug( 'Genome::all_gffs: gff auto_genome:|' . $gff->auto_genome . '|' )
# if $c->debug;
# }
#
# }
#
#}

#-------------------------------------------------------------------------------
Expand All @@ -247,12 +209,12 @@ sub get_chromosomes : Private {
{ genome_acc => $c->stash->{entry} } ] },
{ join => [ qw( genome_gffs ) ],
order_by => [ qw( auto_genome ) ] } );

unless ( @genomes ) {
$c->log->debug( 'Genome::get_chromosomes: failed to find any chromosomes for "'
. $c->stash->{entry} . '"' )
if $c->debug;

$c->stash->{errorMsg} = "No genome for taxonomy ID $c->stash->{entry}";

return;
Expand All @@ -261,7 +223,7 @@ sub get_chromosomes : Private {
$c->stash->{chromosomes} = \@genomes;
$c->stash->{ncbi_id} = $genomes[0]->ncbi_id;
$c->stash->{genome_acc} = $genomes[0]->genome_acc;

$c->log->debug( 'Genome::get_chromosomes: found ' . scalar @{ $c->stash->{chromosomes} } . ' chromosome rows' )
if $c->debug;
}
Expand All @@ -283,7 +245,7 @@ sub get_genome_data : Private {
unless ( defined $summary ) {
$c->log->debug( "Genome::get_genome_data: failed to find a genome summary for ncbi_id $c->stash->{ncbi_id}" )
if $c->debug;

$c->stash->{errorMsg} = "No genome summary for genome identifier $c->stash->{entry}";

return;
Expand Down Expand Up @@ -316,9 +278,9 @@ sub get_regions : Private {
$c->model('RfamDB::RfamRegFull')
->search( { auto_genome => $ag },
{ join => [ qw( auto_rfam ) ],
select => [ qw( auto_rfam.rfam_id
auto_rfam.rfam_acc
genome_start
select => [ qw( auto_rfam.rfam_id
auto_rfam.rfam_acc
genome_start
genome_end
bits_score ) ],
as => [ qw( rfam_id
Expand All @@ -328,7 +290,7 @@ sub get_regions : Private {
bits_score ) ],
order_by => [ qw( auto_genome genome_start ) ] } );

$regions->{$ag}->{has_regions}++
$regions->{$ag}->{has_regions}++
if defined $regions->{$ag}->get_column('rfam_id');
}

Expand Down Expand Up @@ -377,7 +339,7 @@ Jennifer Daub, C<[email protected]>
Copyright (c) 2007: Genome Research Ltd.
Authors: John Tate ([email protected]), Paul Gardner ([email protected]),
Authors: John Tate ([email protected]), Paul Gardner ([email protected]),
Jennifer Daub ([email protected])
This is free software; you can redistribute it and/or modify it under
Expand Down
Loading

0 comments on commit 1ade845

Please sign in to comment.