Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BAM index file generation #2712

Merged
merged 1 commit into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions refinery/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ def _get_aux_node_task_state(self, obj):

def _get_file_extension(self, obj):
try:
return FileStoreItem.objects.get(
uuid=obj.file_uuid).get_file_extension()
file_store_item = FileStoreItem.objects.get(uuid=obj.file_uuid)
except (FileStoreItem.DoesNotExist,
FileStoreItem.MultipleObjectsReturned) as e:
logger.debug(e)
FileStoreItem.MultipleObjectsReturned) as exc:
logger.debug(exc)
return None
return file_store_item.get_extension()

def _get_relative_url(self, obj):
return obj.get_relative_file_store_item_url() or None
Expand Down
2 changes: 1 addition & 1 deletion refinery/core/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ def setUp(self):

self.node_filename = "{}.{}".format(
self.node.name,
self.node.get_file_store_item().get_file_extension()
self.node.get_file_store_item().get_extension()
)

# Create AnalysisNodeConnections
Expand Down
2 changes: 1 addition & 1 deletion refinery/data_set_manager/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def generate_auxiliary_file(auxiliary_node, datafile_path,
# Here we are checking for the FileExtension of the ParentNode's
# FileStoreItem because we will create auxiliary files based on what
# said value is
if parent_node_file_store_item.get_file_extension().lower() == "bam":
if parent_node_file_store_item.get_extension().lower() == "bam":
generate_bam_index(auxiliary_file_store_item.uuid, datafile_path)

generate_auxiliary_file.update_state(state=celery.states.SUCCESS)
Expand Down
14 changes: 9 additions & 5 deletions refinery/file_store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,8 @@ def get_file_size(self, report_symlinks=False):
return 0

def get_file_extension(self):
"""Return extension object based on datafile name or source"""
if self.datafile.name:
extension = _get_extension_from_string(self.datafile.name)
else:
extension = _get_extension_from_string(self.source)
"""Return FileExtension object based on datafile name or source"""
extension = self.get_extension()
try:
return FileExtension.objects.get(name=extension)
except FileExtension.DoesNotExist:
Expand All @@ -246,6 +243,13 @@ def get_file_extension(self):
except FileExtension.MultipleObjectsReturned as exc:
raise RuntimeError(exc)

def get_extension(self):
"""Return extension of datafile name or file name in source"""
if self.datafile.name:
return _get_extension_from_string(self.datafile.name)
else:
return _get_extension_from_string(self.source)

def get_file_object(self):
"""Return file object for the data file or None if failed to open"""
try:
Expand Down