Skip to content

Conversation

@mankiddyman
Copy link

Problem

When running ragtag.py scaffold with Python 3.6+, the process fails during FASTA generation with:
TypeError: a bytes-like object is required, not 'dict'

Root Cause

pysam.FastaFile.fetch() returns bytes in Python 3, but the code was trying to pass these bytes directly to reverse_complement() and sys.stdout.write(), which expect strings.

Solution

Added .decode('utf-8') to convert bytes to strings before processing in two locations in ragtag_agp2fa.py:

  • Line 69: Before calling reverse_complement()
  • Line 71: Before calling sys.stdout.write()

Testing

Tested with actual genomic data where the original code was failing. The fix resolves the issue and scaffolding completes successfully.

  • pysam.FastaFile.fetch() returns bytes in Python 3
  • Added .decode('utf-8') to convert bytes to string before processing
  • Fixes TypeError when calling reverse_complement() and sys.stdout.write()
  • Resolves issue where scaffolding fails during FASTA generation

- pysam.FastaFile.fetch() returns bytes in Python 3
- Added .decode('utf-8') to convert bytes to string before processing
- Fixes TypeError when calling reverse_complement() and sys.stdout.write()
- Resolves issue where scaffolding fails during FASTA generation
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

Successfully merging this pull request may close these issues.

1 participant