Skip to content

Instantly share code, notes, and snippets.

@walterst
Created June 20, 2013 22:41
Show Gist options
  • Save walterst/5827416 to your computer and use it in GitHub Desktop.
Save walterst/5827416 to your computer and use it in GitHub Desktop.
Reverse a qual score file. May be needed when trying to match up reverse complemented fasta files.
#!/usr/bin/env python
""" Used to reverse a qual score sequence, which may be needed in cases of
paired fasta/qual files.
Requires QIIME installed to use (created with 1.7.0dev)
Usage:
python reverse_qual_scores.py X Y
where X is qual scores filepath, Y is output reversed filepath
"""
from sys import argv
from qiime.parse import MinimalQualParser
from qiime.split_libraries import format_qual_output
input_qual = open(argv[1], "U")
output_qual = open(argv[2], "w")
for label, seq in MinimalQualParser(input_qual, full_header=True):
output_qual.write(">%s\n%s" % (label, format_qual_output(seq[::-1])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment