This repository was archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Major changes #34
Open
zhaoc1
wants to merge
8
commits into
PennChopMicrobiomeProgram:master
Choose a base branch
from
zhaoc1:major
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Major changes #34
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
68ac2f8
update README for single end read
6c2e242
update main.py with single end option
81b4100
update tools.py for single end option
2e377b1
use python from the environment
3b40968
update test_main with config file option
48e235f
update test_utils for python3
098ff77
benchmark worm from Celeste
47d3931
take kyle's advice about str(None)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| #!/usr/bin/python | ||
| #!/usr/bin/env python | ||
| from decontamlib.main import human_filter_main | ||
| human_filter_main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| #!/usr/bin/python | ||
| #!/usr/bin/env python | ||
| from decontamlib.main import make_index_main | ||
| make_index_main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import json | ||
| from subprocess import call | ||
| import sys, os | ||
|
|
||
| #define abs path | ||
| path = os.path.abspath(os.path.dirname(sys.argv[0])) | ||
| data_path = path + "/data" | ||
|
|
||
| # create directories for summary files and output files if they don't exist | ||
| log_path = data_path + "/log" | ||
| if not os.path.exists(log_path): | ||
| os.mkdir(log_path) | ||
|
|
||
| output_path = data_path + "/output" | ||
| if not os.path.exists(output_path): | ||
| os.mkdir(output_path) | ||
|
|
||
| # for pct between 0.0 and 1.0 | ||
| for p in map(lambda x: x/10.0,range(0,11)): | ||
| #for frac between 0.0 and 1.0 | ||
| for f in map(lambda x: x/10.0,range(0,11)): | ||
| # print pct and frac | ||
| print("pct: " + str(p) + " frac: " + str(f)) | ||
| # name summary files | ||
| hum_sum_file = "{}/humanseqs_{}_{}.json".format(log_path, p, f) | ||
| nonhum_sum_file = "{}/nonhumanseqs_{}_{}.json".format(log_path, p, f) | ||
| # run decontam over human seqs | ||
| call(["decontaminate.py", "--forward-reads", data_path + "/humanseqs.fastq", "--organism", "human", "--pct", str(p), "--frac", str(f), "--output-dir", output_path, "--summary-file", hum_sum_file]) | ||
| # run decontam over nonhuman seqs | ||
| call(["decontaminate.py", "--forward-reads", data_path + "/nonhumanseqs.fastq", "--organism", "human", "--pct", str(p), "--frac", str(f), "--output-dir", output_path, "--summary-file", nonhum_sum_file]) | ||
| # from human seqs summary file, read and print number of true positive ("true" in data) and false negatives ("false" in data) | ||
| # from nonhuman seqs summary file, read and print number of false positives ("true" in data) and true negatives ("false" in data) | ||
| message = ["tru", "fal", "tru"] | ||
| for i, file in enumerate([hum_sum_file, nonhum_sum_file]): | ||
| with open(file) as f: | ||
| data = json.loads(f.read())["data"] | ||
| mess = "{} pos: ".format(message[i]) | ||
| if "true" in data: | ||
| print("{}{}".format(mess, data["true"])) | ||
| else: | ||
| print("{}0".format(mess)) | ||
| mess = "{} neg: ".format(message[i+1]) | ||
| if "false" in data: | ||
| print("{}{}".format(mess, data["false"])) | ||
| else: | ||
| print("{}0".format(mess)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,14 +62,17 @@ def tearDown(self): | |
|
|
||
| def test_with_sam_file(self): | ||
| sam_file = tempfile.NamedTemporaryFile(suffix=".sam", mode="w") | ||
| sam_file.write(b5_sam) | ||
| sam_file.write(b5_sam.encode()) | ||
| sam_file.seek(0) | ||
| self.args.extend(["--sam-file", sam_file.name]) | ||
|
|
||
| # Set executable for BWA to "false" | ||
| # This program always returns non-zero exit status | ||
| self.args.extend(["--method", "bwa"]) | ||
| self.args.extend(["--bwa_fp", "false"]) | ||
| config_file = tempfile.NamedTemporaryFile(suffix=".json") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Config files are probably more trouble than they're worth. Let's not remove the config files now, but just regard this as a sign that things will be much easier once we do. |
||
| config = {"method":"bwa", "bwa_fp":"false"} | ||
| config_file.write(json.dumps(config).encode()) | ||
| config_file.seek(0) | ||
| self.args.extend(["--config-file", config_file.name]) | ||
|
|
||
| human_filter_main(self.args) | ||
|
|
||
|
|
@@ -82,8 +85,10 @@ def test_with_sam_file(self): | |
|
|
||
| def test_keep_sam_file(self): | ||
| index_fp = os.path.join(data_dir, "fakehuman") | ||
| self.args.extend(["--method", "bwa"]) | ||
| self.args.extend(["--index", index_fp]) | ||
| config_file = tempfile.NamedTemporaryFile(suffix=".json") | ||
| config_file.write(json.dumps({'method':'bwa', 'index':index_fp}).encode()) | ||
| config_file.seek(0) | ||
| self.args.extend(["--config-file", config_file.name]) | ||
|
|
||
| self.args.extend(["--keep-sam-file"]) | ||
| human_filter_main(self.args) | ||
|
|
@@ -92,7 +97,11 @@ def test_keep_sam_file(self): | |
|
|
||
|
|
||
| def test_all_human(self): | ||
| self.args.extend(["--method", "all_human"]) | ||
| config_file = tempfile.NamedTemporaryFile(suffix=".json") | ||
| config_file.write(json.dumps({"method": "all_human"}).encode()) | ||
| config_file.seek(0) | ||
| self.args.extend(["--config-file", config_file.name]) | ||
|
|
||
| human_filter_main(self.args) | ||
|
|
||
| with open(self.summary_fp) as f: | ||
|
|
@@ -109,7 +118,11 @@ def test_all_human(self): | |
|
|
||
|
|
||
| def test_no_human(self): | ||
| self.args.extend(["--method", "no_human"]) | ||
| config_file = tempfile.NamedTemporaryFile(suffix=".json") | ||
| config_file.write(str.encode(json.dumps({"method": "no_human"}))) | ||
| config_file.seek(0) | ||
| self.args.extend(["--config-file", config_file.name]) | ||
|
|
||
| human_filter_main(self.args) | ||
|
|
||
| with open(self.summary_fp) as f: | ||
|
|
@@ -127,8 +140,11 @@ def test_no_human(self): | |
|
|
||
| def test_bowtie(self): | ||
| index_fp = os.path.join(data_dir, "fakehuman") | ||
| self.args.extend(["--method", "bowtie2"]) | ||
| self.args.extend(["--index", index_fp]) | ||
| index_fp = os.path.join(data_dir, "fakehuman") | ||
| config_file = tempfile.NamedTemporaryFile(suffix=".json") | ||
| config_file.write(json.dumps({"method": "bowtie2", "index": index_fp}).encode()) | ||
| config_file.seek(0) | ||
| self.args.extend(["--config-file", config_file.name]) | ||
|
|
||
| human_filter_main(self.args) | ||
|
|
||
|
|
@@ -141,8 +157,11 @@ def test_bowtie(self): | |
|
|
||
| def test_bwa(self): | ||
| index_fp = os.path.join(data_dir, "fakehuman") | ||
| self.args.extend(["--method", "bwa"]) | ||
| self.args.extend(["--index", index_fp]) | ||
| index_fp = os.path.join(data_dir, "fakehuman") | ||
| config_file = tempfile.NamedTemporaryFile(suffix=".json") | ||
| config_file.write(json.dumps({"method": "bwa", "index": index_fp}).encode()) | ||
| config_file.seek(0) | ||
| self.args.extend(["--config-file", config_file.name]) | ||
|
|
||
| human_filter_main(self.args) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to remove the scripts directory, and instead have setup.py make the scripts for us. If we make this switch, Python will wire up the correct interpreter for the scripts it creates.
For an example, see the
console_scriptsargument here:https://github.com/kylebittinger/unassigner/blob/master/setup.py