-
Notifications
You must be signed in to change notification settings - Fork 5
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
For runs w/multiple projects, manage adapter-trimmed files #126
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 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 |
---|---|---|
|
@@ -202,6 +202,29 @@ def _move_helper(self, completed_files, regex, samples_in_project, dst): | |
for fp in files_to_move: | ||
move(fp, dst) | ||
|
||
@staticmethod | ||
def _move_trimmed_files(project_name, output_path): | ||
''' | ||
Given output_path, move all fastqs to a new subdir named project_name. | ||
:param project_name: The name of the new folder to be created. | ||
:param output_path: The path to scan for fastq files. | ||
:return: None | ||
''' | ||
|
||
# method made static and output_path made a parameter for easier | ||
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. should this be part of the docstring vs. a comment? 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. Mostly there as a discussion point for us. Better to delete it after. |
||
# testing. | ||
|
||
if exists(output_path): | ||
pattern = f"{output_path}/*.fastq.gz" | ||
|
||
# this directory shouldn't already exist. | ||
makedirs(join(output_path, project_name), exist_ok=False) | ||
|
||
for trimmed_file in list(glob.glob(pattern)): | ||
move(trimmed_file, join(output_path, project_name)) | ||
else: | ||
raise ValueError(f"'{output_path}' does not exist") | ||
|
||
def run(self, callback=None): | ||
# now a single job-script will be created to process all projects at | ||
# the same time, and intelligently handle adapter-trimming as needed | ||
|
@@ -244,6 +267,15 @@ def run(self, callback=None): | |
pattern = f"{source_dir}/*.fastq.gz" | ||
completed_files = list(glob.glob(pattern)) | ||
|
||
# if the 'only-adapter-filtered' directory exists, move the files | ||
# into a unique location so that files from multiple projects | ||
# don't overwrite each other. | ||
trimmed_only_path = join(self.output_path, | ||
'only-adapter-filtered') | ||
|
||
if exists(trimmed_only_path): | ||
NuQCJob._move_trimmed_files(project_name, trimmed_only_path) | ||
|
||
if needs_human_filtering is True: | ||
filtered_directory = join(source_dir, 'filtered_sequences') | ||
else: | ||
|
This file contains 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
Oops, something went wrong.
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.
my concern here is that this folder is at the top of the NuQCJob folder, which potentially means that if there are more than one project with the same filename it could be overwritten; is this possible?
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.
Correct, that's what this PR is fixing. As NuQCJob processes each project, it will move the adapter-trimmed files from only-adapter-filtered into a subdirectory of said folder. This way there will be no overwrites while NuQCJob is running.
This line here is in FastQCJob, which is downstream of NuQCJob. This line is the same line I added to qiita-rc. If the path to _find_projects is a sub-directory of NuQCJob, then this line will have no effect. If however it's passed the path to the entire working directory, this will safely cover that situation.