Commit a0f66cb2 authored by Anton Petrov's avatar Anton Petrov
Browse files

Add ensembl-compara component

parent 13955b03
......@@ -674,17 +674,21 @@ class LncrnaTargetsView(generics.ListAPIView):
return queryset
class LargerPagination(Pagination):
page_size = 50
class EnsemblComparaAPIViewSet(generics.ListAPIView):
"""API endpoint for related sequences identified by Ensembl Compara"""
permission_classes = (AllowAny, )
serializer_class = EnsemblComparaSerializer
pagination_class = Pagination
pagination_class = LargerPagination
def get_queryset(self):
upi = self.kwargs['pk']
taxid = self.kwargs['taxid']
urs_taxid = EnsemblCompara.objects.filter(urs_taxid__id=upi+'_'+taxid).first()
if urs_taxid:
return EnsemblCompara.objects.filter(homology_id=urs_taxid.homology_id).all()
return EnsemblCompara.objects.filter(homology_id=urs_taxid.homology_id).order_by('urs_taxid__description').all()
else:
return []
......@@ -20,6 +20,7 @@ angular.module("routes", []).service('routes', ['$interpolate', function($interp
textSearch: 'search',
expertDbLogo: '/static/img/expert-db-logos/{{ expertDbName }}.png',
apiSecondaryStructuresView: '/api/v1/rna/{{ upi }}/2d/{{ taxid }}',
apiEnsemblComparaView: '/api/v1/rna/{{ upi }}/ensembl-compara/{{ taxid }}',
genomesApi: '/api/v1/genomes/{{ ensemblAssembly }}',
proxy: '/api/internal/proxy?url={{ url }}',
ebiSearch:
......
var ensemblCompara = {
bindings: {
upi: '=',
taxid: '=',
},
controller: ['$http', 'routes', function($http, routes) {
var ctrl = this;
ctrl.error = null;
ctrl.count = 0;
ctrl.next_page = null;
ctrl.ensembl_compara = [];
ctrl.$onInit = function() {
ctrl.displayResults();
};
ctrl.displayResults = function(next_page_url) {
ctrl.fetchEnsemblCompara(next_page_url).then(
function(response) {
ctrl.ensembl_compara = ctrl.ensembl_compara.concat(response.data.results);
ctrl.count = response.data.count;
ctrl.next_page = response.data.next;
},
function(response) {
ctrl.error = "Failed to fetch Ensembl Compara annotations";
}
);
};
ctrl.fetchEnsemblCompara = function(next_page_url) {
if (typeof next_page_url === 'undefined') {
return $http.get(
routes.apiEnsemblComparaView({ upi: ctrl.upi, taxid: ctrl.taxid }),
{ timeout: 20000 }
);
} else {
return $http.get(next_page_url, { timeout: 20000 });
}
};
ctrl.loadMoreResults = function() {
ctrl.displayResults(ctrl.next_page);
};
}],
templateUrl: '/static/js/components/sequence/ensembl-compara/ensembl-compara.html'
};
angular.module("rnaSequence").component("ensemblCompara", ensemblCompara);
<div ng-if="$ctrl.ensembl_compara.length > 0 && !$ctrl.error">
<h2>
Ensembl Compara
<small>
<span>{{ $ctrl.count }} total</span>
<a href="" uib-tooltip="Learn more about Ensembl Compara annotations in RNAcentral &rarr;" style="color:inherit;">
<i class="fa fa-question-circle" aria-hidden="true"></i>
</a>
</small>
</h2>
<div class="force-scrollbars" style="max-height: 300px; overflow-y: scroll;">
<ul>
<li ng-repeat="entry in $ctrl.ensembl_compara">
<a href="/rna/{{ entry.rnacentral_id.id }}">{{ entry.rnacentral_id.description }}</a>
</li>
</ul>
<a href="" class="btn btn-default btn-sm" ng-click="$ctrl.loadMoreResults()" ng-if="$ctrl.count != $ctrl.ensembl_compara.length">Load more</a>
<span ng-if="$ctrl.error">
<i class="fa fa-exclamation-circle fa-2x"></i>
Failed to load data from server
</span>
</div>
<span>
View tree in
<a href="http://www.ensembl.org/Nomascus_leucogenys/Gene/Compara_Tree?g=ENSNLEG00000021462;r=1a:22821011-22821081;t=ENSNLET00000026487" target="_blank">Ensembl</a>
<!-- http://www.ensembl.org/Nomascus_leucogenys/Gene/Compara_Tree?t=<transcript_id> -->
</span>
</div>
......@@ -198,6 +198,7 @@ limitations under the License.
<script src="{% static "js/components/sequence/xrefs/xref-publications/xref-publications.component.js" %}"></script>
<script src="{% static "js/components/sequence/2d/2d.component.js" %}"></script>
<script src="{% static "js/components/sequence/go-annotations/go-annotations.component.js" %}"></script>
<script src="{% static "js/components/sequence/ensembl-compara/ensembl-compara.component.js" %}"></script>
<script src="{% static "js/components/sequence/xrefs/mirbase-word-cloud/mirbase-word-cloud.component.js" %}"></script>
<script src="{% static "js/components/sequence/protein-targets/protein-targets.component.js" %}"></script>
<script src="{% static "js/components/sequence/lncrna-targets/lncrna-targets.component.js" %}"></script>
......
......@@ -208,6 +208,9 @@ limitations under the License.
<p>
</div>
<div>
<ensembl-compara upi="upi" taxid="taxid"></ensembl-compara>
</div>
<div ng-hide="hideGoAnnotations" ng-if="taxid">
<h2>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment