Skip to content

Commit

Permalink
Updated tests for Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
reece committed Apr 7, 2021
1 parent 0143a40 commit 35b2ed0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions tests/test_uta_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ConfigParser
import os
import unittest

Expand Down Expand Up @@ -98,7 +97,7 @@ def setUpClass(cls):
)
cls.session.add(chr8_sa_n)

for ac, tx_info in transcripts.iteritems():
for ac, tx_info in transcripts.items():
t_seq_n = usam.Seq(
seq=tx_info['seq']
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_uta_parsers_geneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Test_parsers_geneinfoparser(unittest.TestCase):

def test1(self):
fn = os.path.join(data_dir, 'gene_info_100human.gz')
gip = uta.parsers.geneinfo.GeneInfoParser(gzip.open(fn))
gip = uta.parsers.geneinfo.GeneInfoParser(gzip.open(fn, "rt"))
gi = gip.next()
self.assertEqual(gi, {
'Full_name_from_nomenclature_authority': 'alpha-1-B glycoprotein',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_uta_parsers_seqgene.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Test_parsers_seqgene(unittest.TestCase):

def test1(self):
fn = os.path.join(data_dir, 'seq_gene_100.md.gz')
parser = uta.parsers.seqgene.SeqGeneParser(gzip.open(fn))
parser = uta.parsers.seqgene.SeqGeneParser(gzip.open(fn, "rt"))
rec = parser.next()
self.assertEqual(rec, {
'chr_orient': '+',
Expand Down
2 changes: 1 addition & 1 deletion uta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Seq(Base):

def _seq_hash(context):
seq = context.current_parameters["seq"]
return None if seq is None else hashlib.md5(seq.upper()).hexdigest()
return None if seq is None else hashlib.md5(seq.upper().encode("ascii")).hexdigest()

def _seq_len(context):
seq = context.current_parameters["seq"]
Expand Down
5 changes: 3 additions & 2 deletions uta/parsers/geneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GeneInfoParser(object):

def __init__(self, fh):
self._fh = fh
header = self._fh.next().rstrip()
header = next(self._fh).rstrip()
if header != "#Format: tax_id GeneID Symbol LocusTag Synonyms dbXrefs chromosome map_location description type_of_gene Symbol_from_nomenclature_authority Full_name_from_nomenclature_authority Nomenclature_status Other_designations Modification_date (tab is used as a separator, pound sign - start of a comment)":
raise UTAError("""gene info doesn't contain expected header; got:\n{header}""".format(
header=header))
Expand All @@ -23,7 +23,8 @@ def __iter__(self):
return self

def next(self):
return self._csvreader.next()
return next(self._csvreader)


# <LICENSE>
# Copyright 2014 UTA Contributors (https://bitbucket.org/biocommons/uta)
Expand Down
2 changes: 1 addition & 1 deletion uta/parsers/seqgene.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SeqGeneParser(object):
def __init__(self, fh, filter=None):
self._fh = fh
self._filter = filter if filter else lambda r: True
header = self._fh.next().rstrip()
header = next(self._fh).rstrip()
if header != "#tax_id chromosome chr_start chr_stop chr_orient contig ctg_start ctg_stop ctg_orient feature_name feature_id feature_type group_label transcript evidence_code":
raise UTAError("""file doesn't contain expected header; got:\n{header}""".format(
header=header))
Expand Down

0 comments on commit 35b2ed0

Please sign in to comment.