Skip to content
Commits on Source (8)
Metadata-Version: 2.1
Name: HTSeq
Version: 0.10.0
Version: 0.11.2
Summary: A framework to process and analyze data from high-throughput sequencing (HTS) assays
Home-page: https://github.com/simon-anders/htseq
Author: Simon Anders
......
......@@ -29,13 +29,15 @@ and are transferring the binaries onto another machine with a compatible
environment (architechture, shared libraries). If you are not sure,
chances are you need them.
Both ``Linux`` and ``OSX`` are supported and binaries are provided for virtually
all ``Linux`` versions and for some ``OSX`` versions (the latter only for ``Python 2.7``
and ``Python 3.6``). A source package which should not require ``Cython`` nor ``SWIG``
is provided for all other cases. ``Windows`` is not officially supported as we don't
have access to a Continuous Integration ``Windows`` machine that supports ``pysam``.
However, if you have built ``HTSeq`` for ``Windows``, please open an issue and we'll
try and include it in the release.
Both **Linux** and **OSX** are supported and binaries are provided for virtually
all Linux versions and for some OSX versions (the latter only for Python 2.7
and 3.6). A source package which should not require ``Cython`` nor ``SWIG``
is provided for all other cases.
**Windows is not officially supported** as we don't have access to a Continuous
Integration Windows machine that supports ``pysam``. However, if you have built
``HTSeq`` for Windows, please open an issue and we'll try and include it in the
release.
Installation
~~~~~~~~~~~~
......@@ -57,6 +59,20 @@ To install directly from PyPI:
</div>
To install a specific version (e.g. version 0.11.0):
.. raw:: html
<div class="highlight highlight-source-shell">
::
pip install 'HTSeq==0.11.0'
.. raw:: html
</div>
If this fails, please install all dependencies first:
.. raw:: html
......
htseq (0.11.2-1) unstable; urgency=medium
* New upstream version
* debhelper 12
* Standards-Version: 4.3.0
* Secure URI in copyright format
* Drop ancient X-Python-Version field
-- Andreas Tille <tille@debian.org> Fri, 11 Jan 2019 23:31:53 +0100
htseq (0.10.0-1) unstable; urgency=medium
* New upstream version
......
......@@ -5,7 +5,7 @@ Uploaders: Diane Trout <diane@ghic.org>,
Section: python
Testsuite: autopkgtest-pkg-python
Priority: optional
Build-Depends: debhelper (>= 11~),
Build-Depends: debhelper (>= 12~),
python-debian,
python-setuptools,
python-all-dev,
......@@ -21,12 +21,10 @@ Build-Depends: debhelper (>= 11~),
swig,
cython,
cython3
Standards-Version: 4.1.4
Standards-Version: 4.3.0
Vcs-Browser: https://salsa.debian.org/med-team/htseq
Vcs-Git: https://salsa.debian.org/med-team/htseq.git
Homepage: http://www-huber.embl.de/users/anders/HTSeq/doc/overview.html
X-Python-Version: >= 2.7
X-Python3-Version: >= 3.4
Package: python-htseq
Architecture: any
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: HTSeq
Upstream-Contact: Simon Anders
Source: https://pypi.python.org/pypi/HTSeq/
......
This diff is collapsed.
__version__ = "0.10.0"
\ No newline at end of file
__version__ = "0.11.2"
\ No newline at end of file
......@@ -41,12 +41,13 @@ def count_reads_in_features(sam_filenames, gff_filename,
r = (r,)
for read in r:
if read is not None:
samoutfile.write(read.original_sam_line.rstrip() +
"\tXF:Z:" + assignment + "\n")
read.optional_fields.append(('XF', assignment))
samoutfile.write(read.get_sam_line() + "\n")
if samouts != "":
if samouts != []:
if len(samouts) != len(sam_filenames):
raise ValueError('Select the same number of SAM input and output files')
raise ValueError(
'Select the same number of SAM input and output files')
# Try to open samout files early in case any of them has issues
for samout in samouts:
with open(samout, 'w'):
......@@ -73,10 +74,12 @@ def count_reads_in_features(sam_filenames, gff_filename,
try:
feature_id = f.attr[id_attribute]
except KeyError:
raise ValueError("Feature %s does not contain a '%s' attribute" %
raise ValueError(
"Feature %s does not contain a '%s' attribute" %
(f.name, id_attribute))
if stranded != "no" and f.iv.strand == ".":
raise ValueError("Feature %s at %s does not have strand information but you are "
raise ValueError(
"Feature %s at %s does not have strand information but you are "
"running htseq-count in stranded mode. Use '--stranded=no'." %
(f.name, f.iv))
features[f.iv] += feature_id
......@@ -116,22 +119,28 @@ def count_reads_in_features(sam_filenames, gff_filename,
lowqual_all = []
nonunique_all = []
for isam, (sam_filename) in enumerate(sam_filenames):
if samouts != '':
if samouts != []:
samoutfile = open(samouts[isam], 'w')
else:
samoutfile = None
try:
if sam_filename != "-":
read_seq_file = SAM_or_BAM_Reader(sam_filename)
read_seq = read_seq_file
first_read = next(iter(read_seq))
else:
if sam_filename == "-":
read_seq_file = SAM_or_BAM_Reader(sys.stdin)
else:
read_seq_file = SAM_or_BAM_Reader(sam_filename)
read_seq_iter = iter(read_seq_file)
# Catch empty BAM files
try:
first_read = next(read_seq_iter)
read_seq = itertools.chain([first_read], read_seq_iter)
pe_mode = first_read.paired_end
except:
first_read = None
pe_mode = False
if first_read is not None:
read_seq = itertools.chain([first_read], read_seq_iter)
else:
read_seq = []
except:
sys.stderr.write(
"Error occured when reading beginning of SAM/BAM file.\n")
......@@ -175,7 +184,10 @@ def count_reads_in_features(sam_filenames, gff_filename,
try:
if r.optional_field("NH") > 1:
nonunique += 1
write_to_samout(r, "__alignment_not_unique", samoutfile)
write_to_samout(
r,
"__alignment_not_unique",
samoutfile)
if multimapped_mode == 'none':
continue
except KeyError:
......@@ -325,7 +337,8 @@ def count_reads_in_features(sam_filenames, gff_filename,
print('\t'.join(["__alignment_not_unique"] + pad + [str(c) for c in nonunique_all]))
def my_showwarning(message, category, filename, lineno=None, file=None, line=None):
def my_showwarning(message, category, filename, lineno=None, file=None,
line=None):
sys.stderr.write("Warning: %s\n" % message)
......@@ -396,9 +409,11 @@ def main():
"suitable for Ensembl GTF files: gene_id)")
pa.add_argument(
"--additional-attr", type=str, nargs='+',
default=(), help="Additional feature attributes (default: none, " +
"suitable for Ensembl GTF files: gene_name)")
"--additional-attr", type=str,
action='append',
default=[], help="Additional feature attributes (default: none, " +
"suitable for Ensembl GTF files: gene_name). Use multiple times " +
"for each different attribute")
pa.add_argument(
"-m", "--mode", dest="mode",
......@@ -414,19 +429,20 @@ def main():
pa.add_argument(
"--secondary-alignments", dest="secondary_alignments", type=str,
choices=("score", "ignore"), default="score",
choices=("score", "ignore"), default="ignore",
help="Whether to score secondary alignments (0x100 flag)")
pa.add_argument(
"--supplementary-alignments", dest="supplementary_alignments", type=str,
choices=("score", "ignore"), default="score",
choices=("score", "ignore"), default="ignore",
help="Whether to score supplementary alignments (0x800 flag)")
pa.add_argument(
"-o", "--samout", type=str, dest="samouts", nargs='+',
default="", help="write out all SAM alignment records into an output " +
"SAM file called SAMOUT, annotating each line with its feature assignment " +
"(as an optional field with tag 'XF')")
"-o", "--samout", type=str, dest="samouts",
action='append',
default=[], help="write out all SAM alignment records into " +
"SAM files (one per input file needed), annotating each line " +
"with its feature assignment (as an optional field with tag 'XF')")
pa.add_argument(
"-q", "--quiet", action="store_true", dest="quiet",
......
......@@ -5,11 +5,14 @@
# (c) Simon Anders, European Molecular Biology Laboratory, 2010
# released under GNU General Public License
import sys, time, os.path, optparse
import sys
import os.path
import optparse
from itertools import *
import numpy
import HTSeq
def main():
try:
......@@ -26,10 +29,10 @@ def main():
except ImportError:
from matplotlib.pyplot import normalize as Normalize
# **** Parse command line ****
optParser = optparse.OptionParser( usage = "%prog [options] read_file",
optParser = optparse.OptionParser(
usage="%prog [options] read_file",
description=
"This script take a file with high-throughput sequencing reads " +
"(supported formats: SAM, Solexa _export.txt, FASTQ, Solexa " +
......@@ -41,20 +44,26 @@ def main():
"Written by Simon Anders (sanders@fs.tum.de), European Molecular Biology " +
" Laboratory (EMBL). (c) 2010. Released under the terms of the GNU General " +
" Public License v3. Part of the 'HTSeq' framework, version %s." % HTSeq.__version__)
optParser.add_option( "-t", "--type", type="choice", dest="type",
optParser.add_option(
"-t", "--type", type="choice", dest="type",
choices=("sam", "bam", "solexa-export", "fastq", "solexa-fastq"),
default="sam", help="type of read_file (one of: sam [default], bam, " +
"solexa-export, fastq, solexa-fastq)")
optParser.add_option( "-o", "--outfile", type="string", dest="outfile",
optParser.add_option(
"-o", "--outfile", type="string", dest="outfile",
help="output filename (default is <read_file>.pdf)")
optParser.add_option( "-r", "--readlength", type="int", dest="readlen",
optParser.add_option(
"-r", "--readlength", type="int", dest="readlen",
help="the maximum read length (when not specified, the script guesses from the file")
optParser.add_option( "-g", "--gamma", type="float", dest="gamma",
optParser.add_option(
"-g", "--gamma", type="float", dest="gamma",
default = 0.3,
help="the gamma factor for the contrast adjustment of the quality score plot")
optParser.add_option( "-n", "--nosplit", action="store_true", dest="nosplit",
optParser.add_option(
"-n", "--nosplit", action="store_true", dest="nosplit",
help="do not split reads in unaligned and aligned ones")
optParser.add_option( "-m", "--maxqual", type="int", dest="maxqual", default=41,
optParser.add_option(
"-m", "--maxqual", type="int", dest="maxqual", default=41,
help="the maximum quality score that appears in the data (default: 41)")
if len(sys.argv) == 1:
......@@ -64,7 +73,9 @@ def main():
(opts, args) = optParser.parse_args()
if len(args) != 1:
sys.stderr.write( sys.argv[0] + ": Error: Please provide one argument (the read_file).\n" )
sys.stderr.write(
sys.argv[0] +
": Error: Please provide one argument (the read_file).\n")
sys.stderr.write(" Call with '-h' to get usage information.\n")
sys.exit(1)
......@@ -95,7 +106,6 @@ def main():
else:
outfilename = opts.outfile
# **** Get read length ****
if opts.readlen is not None:
......@@ -113,7 +123,6 @@ def main():
max_qual = opts.maxqual
gamma = opts.gamma
# **** Initialize count arrays ****
base_arr_U = numpy.zeros((readlen, 5), numpy.int)
......@@ -122,7 +131,6 @@ def main():
base_arr_A = numpy.zeros((readlen, 5), numpy.int)
qual_arr_A = numpy.zeros((readlen, max_qual+1), numpy.int)
# **** Main counting loop ****
i = 0
......@@ -147,7 +155,6 @@ def main():
raise
print i, "reads processed"
# **** Normalize result ****
def norm_by_pos(arr):
......@@ -162,7 +169,6 @@ def main():
arr_n[arr == 0] = 0
return arr_n
base_arr_U_n = norm_by_pos(base_arr_U)
qual_arr_U_n = norm_by_start(qual_arr_U)
nreads_U = base_arr_U[0, :].sum()
......@@ -171,7 +177,6 @@ def main():
qual_arr_A_n = norm_by_start(qual_arr_A)
nreads_A = base_arr_A[0, :].sum()
# **** Make plot ****
def plot_bases(arr):
......@@ -197,12 +202,12 @@ def main():
pyplot.subplot(221)
plot_bases(base_arr_U_n)
pyplot.ylabel("proportion of base")
pyplot.title( "non-aligned reads\n%.0f%% (%.3f million)" %
pyplot.title("non-aligned reads\n%.0f%% (%.4f million)" %
(100. * nreads_U / (nreads_U+nreads_A), nreads_U / 1e6))
pyplot.subplot(222)
plot_bases(base_arr_A_n)
pyplot.title( "aligned reads\n%.0f%% (%.3f million)" %
pyplot.title("aligned reads\n%.0f%% (%.4f million)" %
(100. * nreads_A / (nreads_U+nreads_A), nreads_A / 1e6))
pyplot.subplot(223)
......@@ -232,8 +237,8 @@ def main():
pyplot.xlabel("position in read")
pyplot.ylabel("base-call quality score")
pyplot.savefig(outfilename)
if __name__ == "__main__":
main()
......@@ -20,7 +20,7 @@ cdef class Sequence( object ):
cdef public bytes seq
cdef public str name
cdef public str descr
cpdef Sequence get_reverse_complement( self )
cpdef Sequence get_reverse_complement(self, bint rename=?)
cpdef object add_bases_to_count_array(Sequence self, numpy.ndarray count_array_)
cpdef Sequence trim_left_end(Sequence self, Sequence pattern, float mismatch_prop=?)
cpdef Sequence trim_right_end(Sequence self, Sequence pattern, float mismatch_prop=?)
......
......@@ -651,10 +651,15 @@ cdef class Sequence(object):
self.name = name
self.descr = None
cpdef Sequence get_reverse_complement(self):
cpdef Sequence get_reverse_complement(self, bint rename=True):
if rename:
return Sequence(
reverse_complement(self.seq),
"revcomp_of_" + self.name)
else:
return Sequence(
reverse_complement(self.seq),
self.name)
def __str__(self):
return self.seq
......@@ -903,13 +908,20 @@ cdef class SequenceWithQualities(Sequence):
self.write_to_fastq_file(sio, convert_to_phred)
return sio.getvalue()
cpdef SequenceWithQualities get_reverse_complement(self):
cpdef SequenceWithQualities get_reverse_complement(self, bint rename=True):
cdef SequenceWithQualities res
if rename:
res = SequenceWithQualities(
reverse_complement(self.seq),
"revcomp_of_" + self.name,
self._qualstr[::-1],
self._qualscale)
else:
res = SequenceWithQualities(
reverse_complement(self.seq),
self.name,
self._qualstr[::-1],
self._qualscale)
if self._qualarr is not None:
res._qualarr = self._qualarr[::-1]
return res
......
This diff is collapsed.
__version__ = "0.10.0"
\ No newline at end of file
__version__ = "0.11.2"
\ No newline at end of file
......@@ -41,10 +41,10 @@ def count_reads_in_features(sam_filenames, gff_filename,
r = (r,)
for read in r:
if read is not None:
samoutfile.write(read.original_sam_line.rstrip() +
"\tXF:Z:" + assignment + "\n")
read.optional_fields.append(('XF', assignment))
samoutfile.write(read.get_sam_line() + "\n")
if samouts != "":
if samouts != []:
if len(samouts) != len(sam_filenames):
raise ValueError('Select the same number of SAM input and output files')
# Try to open samout files early in case any of them has issues
......@@ -116,22 +116,28 @@ def count_reads_in_features(sam_filenames, gff_filename,
lowqual_all = []
nonunique_all = []
for isam, (sam_filename) in enumerate(sam_filenames):
if samouts != '':
if samouts != []:
samoutfile = open(samouts[isam], 'w')
else:
samoutfile = None
try:
if sam_filename != "-":
read_seq_file = SAM_or_BAM_Reader(sam_filename)
read_seq = read_seq_file
first_read = next(iter(read_seq))
else:
if sam_filename == "-":
read_seq_file = SAM_or_BAM_Reader(sys.stdin)
else:
read_seq_file = SAM_or_BAM_Reader(sam_filename)
read_seq_iter = iter(read_seq_file)
# Catch empty BAM files
try:
first_read = next(read_seq_iter)
read_seq = itertools.chain([first_read], read_seq_iter)
pe_mode = first_read.paired_end
except:
first_read = None
pe_mode = False
if first_read is not None:
read_seq = itertools.chain([first_read], read_seq_iter)
else:
read_seq = []
except:
sys.stderr.write(
"Error occured when reading beginning of SAM/BAM file.\n")
......@@ -139,12 +145,20 @@ def count_reads_in_features(sam_filenames, gff_filename,
try:
if pe_mode:
if ((supplementary_alignment_mode == 'ignore') and
(secondary_alignment_mode == 'ignore')):
primary_only = True
else:
primary_only = False
if order == "name":
read_seq = HTSeq.pair_SAM_alignments(read_seq)
read_seq = HTSeq.pair_SAM_alignments(
read_seq,
primary_only=primary_only)
elif order == "pos":
read_seq = HTSeq.pair_SAM_alignments_with_buffer(
read_seq,
max_buffer_size=max_buffer_size)
max_buffer_size=max_buffer_size,
primary_only=primary_only)
else:
raise ValueError("Illegal order specified.")
empty = 0
......@@ -396,9 +410,11 @@ def main():
"suitable for Ensembl GTF files: gene_id)")
pa.add_argument(
"--additional-attr", type=str, nargs='+',
default=(), help="Additional feature attributes (default: none, " +
"suitable for Ensembl GTF files: gene_name)")
"--additional-attr", type=str,
action='append',
default=[], help="Additional feature attributes (default: none, " +
"suitable for Ensembl GTF files: gene_name). Use multiple times " +
"for each different attribute")
pa.add_argument(
"-m", "--mode", dest="mode",
......@@ -414,19 +430,20 @@ def main():
pa.add_argument(
"--secondary-alignments", dest="secondary_alignments", type=str,
choices=("score", "ignore"), default="score",
choices=("score", "ignore"), default="ignore",
help="Whether to score secondary alignments (0x100 flag)")
pa.add_argument(
"--supplementary-alignments", dest="supplementary_alignments", type=str,
choices=("score", "ignore"), default="score",
choices=("score", "ignore"), default="ignore",
help="Whether to score supplementary alignments (0x800 flag)")
pa.add_argument(
"-o", "--samout", type=str, dest="samouts", nargs='+',
default="", help="write out all SAM alignment records into an output " +
"SAM file called SAMOUT, annotating each line with its feature assignment " +
"(as an optional field with tag 'XF')")
"-o", "--samout", type=str, dest="samouts",
action='append',
default=[], help="write out all SAM alignment records into " +
"SAM files (one per input file needed), annotating each line " +
"with its feature assignment (as an optional field with tag 'XF')")
pa.add_argument(
"-q", "--quiet", action="store_true", dest="quiet",
......
......@@ -5,11 +5,14 @@
# (c) Simon Anders, European Molecular Biology Laboratory, 2010
# released under GNU General Public License
import sys, time, os.path, optparse
import sys
import os.path
import optparse
from itertools import *
import numpy
import HTSeq
def main():
try:
......@@ -26,10 +29,10 @@ def main():
except ImportError:
from matplotlib.pyplot import normalize as Normalize
# **** Parse command line ****
optParser = optparse.OptionParser( usage = "%prog [options] read_file",
optParser = optparse.OptionParser(
usage="%prog [options] read_file",
description=
"This script take a file with high-throughput sequencing reads " +
"(supported formats: SAM, Solexa _export.txt, FASTQ, Solexa " +
......@@ -41,20 +44,26 @@ def main():
"Written by Simon Anders (sanders@fs.tum.de), European Molecular Biology " +
" Laboratory (EMBL). (c) 2010. Released under the terms of the GNU General " +
" Public License v3. Part of the 'HTSeq' framework, version %s." % HTSeq.__version__)
optParser.add_option( "-t", "--type", type="choice", dest="type",
optParser.add_option(
"-t", "--type", type="choice", dest="type",
choices=("sam", "bam", "solexa-export", "fastq", "solexa-fastq"),
default="sam", help="type of read_file (one of: sam [default], bam, " +
"solexa-export, fastq, solexa-fastq)")
optParser.add_option( "-o", "--outfile", type="string", dest="outfile",
optParser.add_option(
"-o", "--outfile", type="string", dest="outfile",
help="output filename (default is <read_file>.pdf)")
optParser.add_option( "-r", "--readlength", type="int", dest="readlen",
optParser.add_option(
"-r", "--readlength", type="int", dest="readlen",
help="the maximum read length (when not specified, the script guesses from the file")
optParser.add_option( "-g", "--gamma", type="float", dest="gamma",
optParser.add_option(
"-g", "--gamma", type="float", dest="gamma",
default=0.3,
help="the gamma factor for the contrast adjustment of the quality score plot")
optParser.add_option( "-n", "--nosplit", action="store_true", dest="nosplit",
optParser.add_option(
"-n", "--nosplit", action="store_true", dest="nosplit",
help="do not split reads in unaligned and aligned ones")
optParser.add_option( "-m", "--maxqual", type="int", dest="maxqual", default=41,
optParser.add_option(
"-m", "--maxqual", type="int", dest="maxqual", default=41,
help="the maximum quality score that appears in the data (default: 41)")
if len(sys.argv) == 1:
......@@ -64,7 +73,8 @@ def main():
(opts, args) = optParser.parse_args()
if len(args) != 1:
sys.stderr.write( sys.argv[0] + ": Error: Please provide one argument (the read_file).\n" )
sys.stderr.write(
sys.argv[0] + ": Error: Please provide one argument (the read_file).\n")
sys.stderr.write(" Call with '-h' to get usage information.\n")
sys.exit(1)
......@@ -95,7 +105,6 @@ def main():
else:
outfilename = opts.outfile
# **** Get read length ****
if opts.readlen is not None:
......@@ -113,7 +122,6 @@ def main():
max_qual = opts.maxqual
gamma = opts.gamma
# **** Initialize count arrays ****
base_arr_U = numpy.zeros((readlen, 5), numpy.int)
......@@ -122,7 +130,6 @@ def main():
base_arr_A = numpy.zeros((readlen, 5), numpy.int)
qual_arr_A = numpy.zeros((readlen, max_qual+1), numpy.int)
# **** Main counting loop ****
i = 0
......@@ -147,7 +154,6 @@ def main():
raise
print(i, "reads processed")
# **** Normalize result ****
def norm_by_pos(arr):
......@@ -162,7 +168,6 @@ def main():
arr_n[arr == 0] = 0
return arr_n
base_arr_U_n = norm_by_pos(base_arr_U)
qual_arr_U_n = norm_by_start(qual_arr_U)
nreads_U = base_arr_U[0, :].sum()
......@@ -171,7 +176,6 @@ def main():
qual_arr_A_n = norm_by_start(qual_arr_A)
nreads_A = base_arr_A[0, :].sum()
# **** Make plot ****
def plot_bases(arr):
......@@ -197,12 +201,12 @@ def main():
pyplot.subplot(221)
plot_bases(base_arr_U_n)
pyplot.ylabel("proportion of base")
pyplot.title( "non-aligned reads\n%.0f%% (%.3f million)" %
pyplot.title("non-aligned reads\n%.0f%% (%.4f million)" %
(100. * nreads_U / (nreads_U+nreads_A), nreads_U / 1e6))
pyplot.subplot(222)
plot_bases(base_arr_A_n)
pyplot.title( "aligned reads\n%.0f%% (%.3f million)" %
pyplot.title("aligned reads\n%.0f%% (%.4f million)" %
(100. * nreads_A / (nreads_U+nreads_A), nreads_A / 1e6))
pyplot.subplot(223)
......@@ -232,8 +236,8 @@ def main():
pyplot.xlabel("position in read")
pyplot.ylabel("base-call quality score")
pyplot.savefig(outfilename)
if __name__ == "__main__":
main()
......@@ -20,7 +20,7 @@ cdef class Sequence( object ):
cdef public bytes seq
cdef public str name
cdef public str descr
cpdef Sequence get_reverse_complement( self )
cpdef Sequence get_reverse_complement(self, bint rename=?)
cpdef object add_bases_to_count_array(Sequence self, numpy.ndarray count_array_)
cpdef Sequence trim_left_end(Sequence self, Sequence pattern, float mismatch_prop=?)
cpdef Sequence trim_right_end(Sequence self, Sequence pattern, float mismatch_prop=?)
......
......@@ -645,10 +645,15 @@ cdef class Sequence(object):
self.name = name
self.descr = None
cpdef Sequence get_reverse_complement(self):
cpdef Sequence get_reverse_complement(self, bint rename=True):
if rename:
return Sequence(
reverse_complement(self.seq),
"revcomp_of_" + self.name)
else:
return Sequence(
reverse_complement(self.seq),
self.name)
def __str__(self):
return self.seq.decode()
......@@ -898,13 +903,20 @@ cdef class SequenceWithQualities(Sequence):
self.write_to_fastq_file(sio, convert_to_phred)
return sio.getvalue()
cpdef SequenceWithQualities get_reverse_complement(self):
cpdef SequenceWithQualities get_reverse_complement(self, bint rename=True):
cdef SequenceWithQualities res
if rename:
res = SequenceWithQualities(
reverse_complement(self.seq),
"revcomp_of_" + self.name,
self._qualstr[::-1],
self._qualscale)
else:
res = SequenceWithQualities(
reverse_complement(self.seq),
self.name,
self._qualstr[::-1],
self._qualscale)
if self._qualarr is not None:
res._qualarr = self._qualarr[::-1]
return res
......