Skip to content

Commit

Permalink
Open in 'r' mode with biopython and in 'rU' with csv
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide Albanese committed Mar 10, 2017
1 parent d5649e8 commit 7508c98
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions micca/api/_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def add_phred_quality(records, defaultq):
"quality file")

# parse records
input_handle = open(input_fn, 'rb')
input_handle = open(input_fn, 'r')
if input_fmt == "fasta-qual":
qual_handle = open(qual_fn, 'rb')
qual_handle = open(qual_fn, 'r')
records = PairedFastaQualIterator(input_handle, qual_handle)
else:
records = SeqIO.parse(input_handle, input_fmt)
Expand Down
2 changes: 1 addition & 1 deletion micca/api/_filterstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _stats(input_fn, topn=None, maxeerates=[0.25, 0.5, 0.75, 1, 1.25, 1.5],
eerate_minlen = np.array([], dtype=np.int, order='C')
eerate_trunclen = np.array([], dtype=np.int, order='C')

with open(input_fn, "rb") as input_handle:
with open(input_fn, "r") as input_handle:
for title, seq, qualstr in FastqGeneralIterator(input_handle):
seqlen = len(seq)
if (seqlen < 1):
Expand Down
2 changes: 1 addition & 1 deletion micca/api/_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _stats(input_fn, topn=None):
qual_sum = np.array([], dtype=np.int, order='C')
eerate_sum = np.array([], dtype=np.float, order='C')

with open(input_fn, "rb") as input_handle:
with open(input_fn, "r") as input_handle:
for title, seq, qualstr in FastqGeneralIterator(input_handle):

seqlen = len(seq)
Expand Down
2 changes: 1 addition & 1 deletion micca/api/_tobiom.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def tobiom(input_fn, output_fn, tax_fn=None, sampledata_fn=None,

# replace the OTU ids with the original sequence ids when found in otuids
if otuids_fn is not None:
with open(otuids_fn, "rb") as otuids_handle:
with open(otuids_fn, "rU") as otuids_handle:
otuids_reader = csv.reader(otuids_handle, delimiter="\t")
otuids = dict([(row[0], row[1]) for row in otuids_reader])

Expand Down
4 changes: 2 additions & 2 deletions micca/api/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def rdp(input_fn, output_fn, gene="16srrna", maxmem=2, minconf=0.8):
queryids = [record.id for record in SeqIO.parse(input_fn, "fasta")]

rdp_temp_dict = dict()
with open(rdp_temp_fn, 'rb') as rdp_temp_handle:
with open(rdp_temp_fn, 'rU') as rdp_temp_handle:
rdp_temp_reader = csv.reader(rdp_temp_handle, delimiter='\t')

for row in rdp_temp_reader:
Expand Down Expand Up @@ -170,7 +170,7 @@ def otuid(input_fn, ref_tax_fn, output_fn):

tax_dict = micca.tax.read(ref_tax_fn)

input_handle = open(input_fn, 'rb')
input_handle = open(input_fn, 'rU')
input_reader = csv.reader(input_handle, delimiter='\t')

output_handle = open(output_fn, 'wb')
Expand Down
6 changes: 3 additions & 3 deletions micca/api/msa.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _nast_core(template, template_aln, candidate_aln):
def _msa_count_columns(input_fn):
"""Count columns in a MSA in FASTA format.
"""
with open(input_fn, "rb") as input_handle:
with open(input_fn, "r") as input_handle:
parser = SimpleFastaParser(input_handle)
try:
title, seq = parser.next()
Expand All @@ -127,7 +127,7 @@ def _msa_remove_gaps(input_fn, output_fn):
"""Write a new file without gap characters (-).
"""

input_handle = open(input_fn, "rb")
input_handle = open(input_fn, "r")
output_handle = open(output_fn, "wb")

for title, seq in SimpleFastaParser(input_handle):
Expand Down Expand Up @@ -313,7 +313,7 @@ def nast(input_fn, template_fn, output_fn, notaligned_fn=None, hits_fn=None,
if nofilter:
os.rename(output_temp_fn, output_fn)
else:
output_temp_handle = open(output_temp_fn, "rb")
output_temp_handle = open(output_temp_fn, "r")
output_handle = open(output_fn, "wb")
for title, seq in SimpleFastaParser(output_temp_handle):
seqout = "".join(np.array(list(seq))[msa_cov > 0])
Expand Down
2 changes: 1 addition & 1 deletion micca/api/otu.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _rename_seqids(input_fn, otuids_fn, prefix=""):
output_dir = os.path.dirname(input_fn)

tmp_fn = micca.ioutils.make_tempfile(output_dir)
input_handle = open(input_fn, "rb")
input_handle = open(input_fn, "r")
otuids_handle = open(otuids_fn, "wb")
tmp_handle = open(tmp_fn, "wb")

Expand Down

0 comments on commit 7508c98

Please sign in to comment.