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

Empty PAF #7

Closed
schorlton opened this issue Jan 10, 2022 · 7 comments
Closed

Empty PAF #7

schorlton opened this issue Jan 10, 2022 · 7 comments

Comments

@schorlton
Copy link

Hi @alexomics ,

Thanks again for the great tool!

I hit a bug where I had an empty PAF (no read alignments, this seems to be valid output from minimap2?). Tried reading this in with parse_paf into a pandas dataframe but fails (I believe because of the tag columns). Is it possible to produce an empty df? Should this be the desired behaviour?

To reproduce:

touch test.paf
from readpaf import parse_paf

with open("test.paf", "r") as handle:
    df = parse_paf(handle, dataframe=True)

Thanks!

alexomics added a commit that referenced this issue Jan 10, 2022
Add a test case and skip parsing tags for empty pd.DataFrame.
@alexomics
Copy link
Owner

I've added a branch issue7 that has a test/fix for this. You should be able to install this version (0.0.10a1) using:

pip install --upgrade git+https://github.com/alexomics/read-paf@issue7

Let me know if that works 😊

@alexomics
Copy link
Owner

There may also be a better way of checking if the DataFrame is empty, see: https://stackoverflow.com/a/24933234. Though it's worth considering what is empty? E.g: no rows and named columns?

@schorlton
Copy link
Author

Wow, thanks for such as fast response and fix! I wonder if the columns of the df should be the standard 12 PAF columns (same as if there were alignments), with just no rows as you allude to above? Currently, I'm getting just an empty df with no columns.

@schorlton
Copy link
Author

Hi @alexomics , just wondering if you could point me in the easiest way to retain the field headers of the df even if the PAF is empty? Thanks!

@alexomics
Copy link
Owner

The easiest way is for me to return the DataFrame with the column names already there 😅

If you give v0.0.10a2 a go let me know if that works or has any unexpected behaviour. I'll try to get this on to PyPI ASAP!

@schorlton
Copy link
Author

Wow, thanks so much! Gave it a go and it's great!

alexomics added a commit that referenced this issue Jan 19, 2022
alexomics added a commit that referenced this issue Jan 19, 2022
Add a test case and skip parsing tags for empty pd.DataFrame.
alexomics added a commit that referenced this issue Jan 19, 2022
@alexomics
Copy link
Owner

I've published this as v0.0.10. Thanks for testing it out!

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

2 participants