Commit d308874b authored by carlosribas's avatar carlosribas
Browse files

Exclude region with status different than "clustered"

parent bcd78ebe
...@@ -16,6 +16,7 @@ import requests ...@@ -16,6 +16,7 @@ import requests
import zlib import zlib
from itertools import chain from itertools import chain
from django.db import connection
from django.http import Http404, HttpResponse from django.http import Http404, HttpResponse
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django_filters import rest_framework as filters from django_filters import rest_framework as filters
...@@ -31,17 +32,17 @@ from rest_framework_jsonp.renderers import JSONPRenderer ...@@ -31,17 +32,17 @@ from rest_framework_jsonp.renderers import JSONPRenderer
from rest_framework_yaml.renderers import YAMLRenderer from rest_framework_yaml.renderers import YAMLRenderer
from apiv1.serializers import RnaNestedSerializer, AccessionSerializer, CitationSerializer, XrefSerializer, \ from apiv1.serializers import RnaNestedSerializer, AccessionSerializer, CitationSerializer, XrefSerializer, \
RnaFlatSerializer, RnaFastaSerializer, RnaGffSerializer, RnaGff3Serializer, RnaBedSerializer, \ RnaFlatSerializer, RnaFastaSerializer, RnaGffSerializer, RnaGff3Serializer, \
RnaSpeciesSpecificSerializer, ExpertDatabaseStatsSerializer, \ RnaBedSerializer, RnaSpeciesSpecificSerializer, ExpertDatabaseStatsSerializer, \
RawPublicationSerializer, RnaSecondaryStructureSerializer, \ RawPublicationSerializer, RnaSecondaryStructureSerializer, \
RfamHitSerializer, SequenceFeatureSerializer, \ RfamHitSerializer, SequenceFeatureSerializer, \
EnsemblAssemblySerializer, ProteinTargetsSerializer, \ EnsemblAssemblySerializer, ProteinTargetsSerializer, \
LncrnaTargetsSerializer, EnsemblComparaSerializer, SecondaryStructureSVGImageSerializer LncrnaTargetsSerializer, EnsemblComparaSerializer, SecondaryStructureSVGImageSerializer
from apiv1.renderers import RnaFastaRenderer from apiv1.renderers import RnaFastaRenderer
from portal.models import Rna, RnaPrecomputed, Accession, Xref, Database, DatabaseStats, RfamHit, EnsemblAssembly,\ from portal.models import Rna, RnaPrecomputed, Accession, Database, DatabaseStats, RfamHit, EnsemblAssembly, \
GoAnnotation, RelatedSequence, ProteinInfo, SequenceFeature,\ GoAnnotation, RelatedSequence, ProteinInfo, SequenceFeature, SequenceRegion, EnsemblCompara, \
SequenceRegion, EnsemblCompara, SecondaryStructureWithLayout SecondaryStructureWithLayout, dictfetchall
from portal.config.expert_databases import expert_dbs from portal.config.expert_databases import expert_dbs
from rnacentral.utils.pagination import Pagination, PaginatedRawQuerySet from rnacentral.utils.pagination import Pagination, PaginatedRawQuerySet
...@@ -449,26 +450,38 @@ class RnaGenomeLocations(generics.ListAPIView): ...@@ -449,26 +450,38 @@ class RnaGenomeLocations(generics.ListAPIView):
output = [] output = []
for region in regions: for region in regions:
output.append({ # check the gene status for each region
'chromosome': region.chromosome, query = '''
'strand': region.strand, SELECT status
'start': region.region_start, FROM rnc_gene_status
'end': region.region_stop, WHERE region_id = '{region_id}'
'identity': region.identity, '''.format(region_id=region.id)
'species': assembly.ensembl_url, with connection.cursor() as cursor:
'ucsc_db_id': assembly.assembly_ucsc, cursor.execute(query)
'ensembl_division': { data = dictfetchall(cursor)
'name': assembly.division,
'url': 'http://' + assembly.subdomain # show results only from those with "clustered" status
}, if data[0]['status'] == "clustered":
'ensembl_species_url': assembly.ensembl_url output.append({
}) 'chromosome': region.chromosome,
'strand': region.strand,
'start': region.region_start,
'end': region.region_stop,
'identity': region.identity,
'species': assembly.ensembl_url,
'ucsc_db_id': assembly.assembly_ucsc,
'ensembl_division': {
'name': assembly.division,
'url': 'http://' + assembly.subdomain
},
'ensembl_species_url': assembly.ensembl_url
})
exceptions = ['X', 'Y'] exceptions = ['X', 'Y']
if re.match(r'\d+', output[-1]['chromosome']) or output[-1]['chromosome'] in exceptions: if re.match(r'\d+', output[-1]['chromosome']) or output[-1]['chromosome'] in exceptions:
output[-1]['ucsc_chromosome'] = 'chr' + output[-1]['chromosome'] output[-1]['ucsc_chromosome'] = 'chr' + output[-1]['chromosome']
else: else:
output[-1]['ucsc_chromosome'] = output[-1]['chromosome'] output[-1]['ucsc_chromosome'] = output[-1]['chromosome']
return Response(output) return Response(output)
......
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