Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Framework #3

Merged
merged 8 commits into from
Apr 26, 2022
Merged

Testing Framework #3

merged 8 commits into from
Apr 26, 2022

Conversation

evanmwilliams
Copy link
Contributor

Made some modifications to depth.py and added a program to format output of odgi depth

Copy link
Collaborator

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's headed in the right direction! I left a few high-level comments within.

I would recommend not committing the output files to the repository. To test, we probably want to compare what the tools output at that instant instead of whenever the outputs were previously generated and checked into the repo. So leaving them out (and possibly even adding them to .gitignore) would be a good way to ensure that every test gets "fresh" results to compare.

instructions.txt Outdated
Comment on lines 1 to 3
Sorry that the testing process isn't super automated right now!
This will be fixed very soon in the near future. For now, here's
how to do the differential testing:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for writing up the instructions! Go right ahead and put this in the main README.md along with the rest of the instructions for stuff to do with the repository.

Makefile Outdated
Comment on lines 2 to 5
TEST_FILE := DRB1-3123.gfa
GFA_URL := https://raw.githubusercontent.com/pangenome/odgi/ebc493f2622f49f1e67c63c1935d68967cd16d85/test

.PHONY: fetch
.PHONY: fetch test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just stating the obvious: looks like these Makefile changes aren't used for now.

depth.py Outdated
Comment on lines 18 to 21
with open('python_output.txt', 'w') as f:
depth_items = depth_map.items()
for pair in depth_items:
f.write(f'{pair[0]} {pair[1]}\n')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just printing this this to stdout would be simpler. If you just do print(f'...') instead of opening a text file as output, it remains possible to both see the output in your console or write it to a file. That is, you can do this:

$ python3 depth.py something.gfa

to see the output with your eyes, or use shell redirection:

$ python3 depth.py > output.txt

to write it to output.txt for testing/comparison purposes. Leaving the output file non-hardcoded will make it easier to manipulate the output when necessary.

Copy link
Collaborator

@sampsyo sampsyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Added a few comments—one high-level suggestion is to make the various command-line tools read from stdin and write to stdout, which will avoid hard-coding specific filenames to read/write. (This will make the tools easier for humans to use and also make them more flexible as we build more tooling around them.)

@@ -8,13 +8,16 @@ def depth(filename):

for path in g.paths:
for segment in path.segment_names:
name = segment.name
name = int(segment.name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know that segment names are always numbers? (If not, then this call to int(...) might crash.)

Comment on lines +18 to +20
with open('python_output.txt', 'w') as f:
for pair in sorted_depth_items:
f.write(f'{pair[0]} {pair[1]}\n')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend just printing this to standard output: i.e., just use print, not f.write (and no need to hard-code an output filename). This will make it easier to use the various scripts for different purposes in the future.

Comment on lines +18 to +20
python3 process.py temp_depth.txt

python3 depth.py $OPTARG
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you take my suggestion above to avoid hard-coding the output filename, you can do > python_output.txt here.

@@ -0,0 +1,11 @@
import sys
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file could use some comments describing what it does.

Comment on lines +9 to +11
with open('odgi_output.txt', 'w') as f2:
for i in range(1, len(data)):
f2.write(f'{data[i][0].strip()} {data[i][1].strip()}\n')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also avoid hard-coding the output filename here too. Just using a normal print will make this print to the standard output stream, making things more flexible.

@@ -0,0 +1,11 @@
import sys

with open(sys.argv[1], 'r') as f:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't critical, but for bonus points, you can avoid needing to take a file name as input by just reading from standard input… that is, read directly from sys.stdin. Then you would invoke this script like:

python3 process.py < input.txt > output.txt

to read data from input.txt and write it to output.txt.

@evanmwilliams evanmwilliams merged commit 23323d8 into main Apr 26, 2022
@evanmwilliams evanmwilliams deleted the test branch April 26, 2022 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants