Skip to content

Commit

Permalink
Fix FASTG spec link; fix CI; small style fixes (#11)
Browse files Browse the repository at this point in the history
* DOC: add internet archive link to FASTG spec

Fixes #9.

* DOC: tidy up link to archived specification

* BLD: pin CI Ubuntu version to 20.04

Fixes half of #10.

* STY/TST: fix flake8 line-length issues in test

this also made the code a lot cleaner, so probs for the best

* STY/BLD: lint/check setup.py; pin black < 22.10
  • Loading branch information
fedarko authored Sep 13, 2023
1 parent bb87d97 commit af044b7
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 85 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ name: pyfastg CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
# Stopgap solution -- "ubuntu-latest" (22.04, as of writing) no longer
# supports Python 3.6. See https://github.com/fedarko/pyfastg/issues/10.
runs-on: ubuntu-20.04

strategy:
matrix:
# Gotta specify 3.10 as a string to avoid it being converted to 3.1:
# https://github.com/actions/setup-python/issues/160
# The -dev after 3.11 is so that we can test on the latest dev version
# of python 3.11, since I believe no stable version of 3.11 exists yet
# (see https://github.com/actions/setup-python/issues/160 again)
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11-dev"]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10", "3.11"]

steps:

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ test:
python3 -B -m pytest pyfastg/tests/ --cov-report xml --cov-report term

stylecheck:
flake8 pyfastg
black --check -l 79 pyfastg
flake8 pyfastg setup.py
black --check -l 79 pyfastg setup.py

style:
black -l 79 pyfastg
black -l 79 pyfastg setup.py
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ accurately representing the ambiguity resulting from sequencing limitations, plo
or other factors that complicate representation of a seqence as a simple string.

The latest specification for the FASTG format is version 1.00, as of writing;
this specification is located [here](http://fastg.sourceforge.net/FASTG_Spec_v1.00.pdf).
the original FASTG website is down, but
an archived version of the v1.00 specification is
[accessible here](https://web.archive.org/web/20211209213905/http://fastg.sourceforge.net/FASTG_Spec_v1.00.pdf).
Whenever the rest of this documentation mentions "the FASTG spec," this is in reference
to this version of the specification.

Expand Down
119 changes: 44 additions & 75 deletions pyfastg/tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
from pyfastg import parse_fastg


# Represents the second line down of a simple FASTG file; we will add in the
# "first line" of this file for a few tests later on below. (Adjusting this
# first line programmatically is easier than writing out, like, five versions
# of this one file.) For reference, a "correct" first line for this file is
# >EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5',EDGE_2_length_3_cov_1;
SIMPLE_LINES = """ATCGCCCAT
>EDGE_1_length_9_cov_4.5':EDGE_2_length_3_cov_1';
ATGGGCGAT
>EDGE_2_length_3_cov_1:EDGE_1_length_9_cov_4.5;
CGA
>EDGE_2_length_3_cov_1';
TCG
>EDGE_3_length_5_cov_16.5:EDGE_1_length_9_cov_4.5',EDGE_2_length_3_cov_1';
GGATC
>EDGE_3_length_5_cov_16.5':EDGE_2_length_3_cov_1';
GATCC
"""


def test_parse_medium_assembly_graph():
digraph = parse_fastg("pyfastg/tests/input/assembly_graph.fastg")
assert len(digraph.nodes) == 66
Expand Down Expand Up @@ -208,21 +227,11 @@ def write_tempfile(text):

def test_parse_whitespace_btwn_adjs():
# " , "
fh = write_tempfile(
""">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5' , EDGE_2_length_3_cov_1;
ATCGCCCAT
>EDGE_1_length_9_cov_4.5':EDGE_2_length_3_cov_1';
ATGGGCGAT
>EDGE_2_length_3_cov_1:EDGE_1_length_9_cov_4.5;
CGA
>EDGE_2_length_3_cov_1';
TCG
>EDGE_3_length_5_cov_16.5:EDGE_1_length_9_cov_4.5',EDGE_2_length_3_cov_1';
GGATC
>EDGE_3_length_5_cov_16.5':EDGE_2_length_3_cov_1';
GATCC
"""
)
t = (
">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5' , EDGE_2_length_"
"3_cov_1;\n"
) + SIMPLE_LINES
fh = write_tempfile(t)
with pytest.raises(ValueError) as ei:
parse_fastg(fh.name)
assert str(ei.value) == (
Expand All @@ -232,21 +241,11 @@ def test_parse_whitespace_btwn_adjs():
)

# " ,"
fh = write_tempfile(
""">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5' ,EDGE_2_length_3_cov_1;
ATCGCCCAT
>EDGE_1_length_9_cov_4.5':EDGE_2_length_3_cov_1';
ATGGGCGAT
>EDGE_2_length_3_cov_1:EDGE_1_length_9_cov_4.5;
CGA
>EDGE_2_length_3_cov_1';
TCG
>EDGE_3_length_5_cov_16.5:EDGE_1_length_9_cov_4.5',EDGE_2_length_3_cov_1';
GGATC
>EDGE_3_length_5_cov_16.5':EDGE_2_length_3_cov_1';
GATCC
"""
)
t = (
">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5' ,EDGE_2_length_"
"3_cov_1;\n"
) + SIMPLE_LINES
fh = write_tempfile(t)
with pytest.raises(ValueError) as ei:
parse_fastg(fh.name)
assert str(ei.value) == (
Expand All @@ -256,21 +255,11 @@ def test_parse_whitespace_btwn_adjs():
)

# ", "
fh = write_tempfile(
""">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5', EDGE_2_length_3_cov_1;
ATCGCCCAT
>EDGE_1_length_9_cov_4.5':EDGE_2_length_3_cov_1';
ATGGGCGAT
>EDGE_2_length_3_cov_1:EDGE_1_length_9_cov_4.5;
CGA
>EDGE_2_length_3_cov_1';
TCG
>EDGE_3_length_5_cov_16.5:EDGE_1_length_9_cov_4.5',EDGE_2_length_3_cov_1';
GGATC
>EDGE_3_length_5_cov_16.5':EDGE_2_length_3_cov_1';
GATCC
"""
)
t = (
">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5', EDGE_2_length_"
"3_cov_1;\n"
) + SIMPLE_LINES
fh = write_tempfile(t)
with pytest.raises(ValueError) as ei:
parse_fastg(fh.name)
assert str(ei.value) == (
Expand All @@ -282,21 +271,11 @@ def test_parse_whitespace_btwn_adjs():

def test_parse_tilde_before_outgoing_adj_name():
"""These are technically supported in the spec, but we don't allow them."""
fh = write_tempfile(
""">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5',~EDGE_2_length_3_cov_1;
ATCGCCCAT
>EDGE_1_length_9_cov_4.5':EDGE_2_length_3_cov_1';
ATGGGCGAT
>EDGE_2_length_3_cov_1:EDGE_1_length_9_cov_4.5;
CGA
>EDGE_2_length_3_cov_1';
TCG
>EDGE_3_length_5_cov_16.5:EDGE_1_length_9_cov_4.5',EDGE_2_length_3_cov_1';
GGATC
>EDGE_3_length_5_cov_16.5':EDGE_2_length_3_cov_1';
GATCC
"""
)
t = (
">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5',~EDGE_2_length_"
"3_cov_1;\n"
) + SIMPLE_LINES
fh = write_tempfile(t)
with pytest.raises(ValueError) as ei:
parse_fastg(fh.name)
assert str(ei.value) == (
Expand All @@ -308,21 +287,11 @@ def test_parse_brackets_after_outgoing_adj_name():
"""Again, technically supported in the spec, but we don't allow this.
This is a way of encoding adjacency-specific properties."""
fh = write_tempfile(
""">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5'[prop=val],EDGE_2_length_3_cov_1;
ATCGCCCAT
>EDGE_1_length_9_cov_4.5':EDGE_2_length_3_cov_1';
ATGGGCGAT
>EDGE_2_length_3_cov_1:EDGE_1_length_9_cov_4.5;
CGA
>EDGE_2_length_3_cov_1';
TCG
>EDGE_3_length_5_cov_16.5:EDGE_1_length_9_cov_4.5',EDGE_2_length_3_cov_1';
GGATC
>EDGE_3_length_5_cov_16.5':EDGE_2_length_3_cov_1';
GATCC
"""
)
t = (
">EDGE_1_length_9_cov_4.5:EDGE_3_length_5_cov_16.5'[prop=val],EDGE_2_"
"length_3_cov_1;\n"
) + SIMPLE_LINES
fh = write_tempfile(t)
with pytest.raises(ValueError) as ei:
parse_fastg(fh.name)
assert str(ei.value) == (
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@
classifiers=classifiers,
packages=find_packages(),
install_requires=["networkx >= 2"],
extras_require={"dev": ["pytest", "pytest-cov", "flake8", "black"]},
extras_require={
# The black < 22.10 pin is because black 22.10 stopped supporting
# python 3.6
"dev": ["pytest", "pytest-cov", "flake8", "black < 22.10"]
},
)

0 comments on commit af044b7

Please sign in to comment.