Skip to content

Commit

Permalink
Fixes broken tests:
Browse files Browse the repository at this point in the history
 - mikado.db was missing orf names
 - pandas is returning UnicodeDecodeError instead of ValueError or ParserError when attempting to process a .h5 file

Summary:
Mikado was not correctly storing the orf names in the DB which meant nodes in the clique graph were being created with "None", the behaviour for handling None as node name was changed in networkx triggering the underlying Mikado issue. (See networkx/networkx#4892)
  • Loading branch information
ljyanesm committed Aug 4, 2021
1 parent 88faf7e commit e807b9a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Mikado/serializers/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __init__(self, handle,

try:
self.data = pd.read_csv(self.handle, delimiter=delimiter, index_col=["tid"])
except (ValueError, pd.errors.ParserError) as exc:
except (ValueError, pd.errors.ParserError, UnicodeDecodeError) as exc:
self.logger.critical("Invalid input file!")
self.logger.critical(exc)
raise
Expand Down
Binary file modified Mikado/tests/mikado.db
Binary file not shown.
12 changes: 6 additions & 6 deletions Mikado/tests/test_db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def test_content(self):
sessionmaker = sqlalchemy.orm.sessionmaker(bind=engine)
session = sessionmaker()
# Simple tests based on the static content of the dictionary
self.assertEqual(session.query(serializers.junction.Junction).count(), 372,
self.assertEqual(session.query(serializers.junction.Junction).count(), 371,
self.json.db_settings)
self.assertEqual(session.query(serializers.orf.Orf).count(), 169)
self.assertEqual(session.query(serializers.blast_serializer.Target).count(), 38909)
self.assertEqual(session.query(serializers.blast_serializer.Query).count(), 93)
self.assertEqual(session.query(serializers.blast_serializer.Hit).count(), 5034)
self.assertEqual(session.query(serializers.blast_serializer.Hsp).count(), 13585)
self.assertEqual(session.query(serializers.orf.Orf).count(), 268)
self.assertEqual(session.query(serializers.blast_serializer.Target).count(), 42992)
self.assertEqual(session.query(serializers.blast_serializer.Query).count(), 112)
self.assertEqual(session.query(serializers.blast_serializer.Hit).count(), 674)
self.assertEqual(session.query(serializers.blast_serializer.Hsp).count(), 674)

first_query = session.query(serializers.blast_serializer.Query).limit(1).one()
astup = first_query.as_tuple()
Expand Down
2 changes: 1 addition & 1 deletion Mikado/tests/test_external_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_invalid_tsv(self):
conf.serialise.files.transcripts)
logger = create_default_logger("test_no_fasta", level="DEBUG")
h5 = pkg_resources.resource_filename("Mikado.tests", os.path.join("test_external", "abundance.h5"))
with self.assertRaises((pd.errors.ParserError,)):
with self.assertRaises((pd.errors.ParserError, UnicodeDecodeError)):
ExternalSerializer(logger=logger, configuration=conf, handle=h5)
wrong_tsv_one = pkg_resources.resource_filename("Mikado.tests", os.path.join("test_external", "wrong_1.tsv"))
with self.assertRaises((ValueError, pd.errors.ParserError)), \
Expand Down

0 comments on commit e807b9a

Please sign in to comment.