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

Do not perform summary if blast is empty #28

Open
svarona opened this issue Jul 17, 2024 · 0 comments
Open

Do not perform summary if blast is empty #28

svarona opened this issue Jul 17, 2024 · 0 comments

Comments

@svarona
Copy link
Member

svarona commented Jul 17, 2024

Sometimes, mapping founds a plasmid, but then BLAST doesn't find any contig matching the plasmid to generate the summary, and plasmidID crushes with:

CREATING SUMMARY REPORT (Fri Jul 12 09:15:06 CEST 2024)
 An html report with miniatures of the images will be generate with useful statistics to determine the correct plasmids in the sample.
Namespace(group=False, input_folder='/scratch/bi/SRVCNM1171_20240711_SPYOGENES07_svaldezate_S/ANALYSIS/20240711_ANALYSIS03_PLASMIDID/NO_GROUP/20231359')
Creating summary
Wrong number of items passed 7, placement implies 1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3080, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 4554, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 4562, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'images'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 3826, in _set_item
    loc = self._info_axis.get_loc(key)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3082, in get_loc
    raise KeyError(key) from err
KeyError: 'images'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/summary_report_pid.py", line 465, in <module>
    main()
  File "/usr/local/bin/summary_report_pid.py", line 458, in main
    final_individual_dataframe = include_images(input_folder, summary_df)
  File "/usr/local/bin/summary_report_pid.py", line 135, in include_images
    summary_df['images'] = summary_df.apply(lambda x: image_finder(x, sample_folder), axis=1)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 3163, in __setitem__
    self._set_item(key, value)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 3243, in _set_item
    NDFrame._set_item(self, key, value)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 3829, in _set_item
    self._mgr.insert(len(self._info_axis), key, value)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 1203, in insert
    block = make_block(values=value, ndim=self.ndim, placement=slice(loc, loc + 1))
  File "/usr/local/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 2742, in make_block
    return klass(values, ndim=ndim, placement=placement)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 143, in __init__
    f"Wrong number of items passed {len(self.values)}, "
ValueError: Wrong number of items passed 7, placement implies 1
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3080, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 4554, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 4562, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'images'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 3826, in _set_item
    loc = self._info_axis.get_loc(key)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3082, in get_loc
    raise KeyError(key) from err
KeyError: 'images'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/summary_report_pid.py", line 465, in <module>
    main()
  File "/usr/local/bin/summary_report_pid.py", line 458, in main
    final_individual_dataframe = include_images(input_folder, summary_df)
  File "/usr/local/bin/summary_report_pid.py", line 135, in include_images
    summary_df['images'] = summary_df.apply(lambda x: image_finder(x, sample_folder), axis=1)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 3163, in __setitem__
    self._set_item(key, value)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/frame.py", line 3243, in _set_item
    NDFrame._set_item(self, key, value)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/generic.py", line 3829, in _set_item
    self._mgr.insert(len(self._info_axis), key, value)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 1203, in insert
    block = make_block(values=value, ndim=self.ndim, placement=slice(loc, loc + 1))
  File "/usr/local/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 2742, in make_block
    return klass(values, ndim=ndim, placement=placement)
  File "/usr/local/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 143, in __init__
    f"Wrong number of items passed {len(self.values)}, "
ValueError: Wrong number of items passed 7, placement implies 1

Possible solution: Do not perform summary when there are no BLAST hits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant