hotdogee / django-blast

NCBI-BLAST web service with python backend and HTML5 frontend.
Other
21 stars 15 forks source link

MultipleObjectsReturned: get() returned more than one Sequence -- it returned 2! #19

Open childers opened 8 years ago

childers commented 8 years ago

This is an odd error. "MultipleObjectsReturned: get() returned more than one Sequence -- it returned 2!"

Internal Server Error: /webapp/blast/api/seq/Mdes007966-RA/ Traceback (most recent call last): File "/usr/local/i5k/virtualenv/py2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response response = wrapped_callback(request, _callback_args, _callback_kwargs) File "/usr/local/i5k/rest_framework/viewsets.py", line 78, in view return self.dispatch(request, _args, _kwargs) File "/usr/local/i5k/virtualenv/py2.7/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(_args, _kwargs) File "/usr/local/i5k/rest_framework/views.py", line 401, in dispatch response = self.handle_exception(exc) File "/usr/local/i5k/rest_framework/views.py", line 398, in dispatch response = handler(request, _args, _kwargs) File "/usr/local/i5k/rest_framework/mixins.py", line 106, in retrieve self.object = self.get_object() File "/usr/local/i5k/rest_framework/generics.py", line 335, in get_object obj = get_object_or_404(queryset, _filter_kwargs) File "/usr/local/i5k/rest_framework/generics.py", line 35, in get_object_or_404 return _get_object_or_404(queryset, filter_args, _filter_kwargs) File "/usr/local/i5k/virtualenv/py2.7/lib/python2.7/site-packages/django/shortcuts.py", line 155, in get_object_or_404 return queryset.get(_args, _kwargs) File "/usr/local/i5k/virtualenv/py2.7/lib/python2.7/site-packages/django/db/models/query.py", line 338, in get (self.model._meta.object_name, num) MultipleObjectsReturned: get() returned more than one Sequence -- it returned 2!

childers commented 8 years ago

The problem is that two features have the same ID in the sequences table, and are in two different BLAST databases:

django=> select * from blast_sequence where id like '%Mdes013216-RA%' ;
   key   | blast_db_id |      id       | length | seq_start_pos | seq_end_pos |         modified_date         
---------+-------------+---------------+--------+---------------+-------------+-------------------------------
 3681541 |         111 | Mdes013216-RA |    171 |       8114470 |     8114659 | 2014-09-22 10:28:52.732733-04
 3704172 |         110 | Mdes013216-RA |    513 |      23863621 |    23864158 | 2014-09-22 10:28:58.362744-04
(2 rows)