-
Notifications
You must be signed in to change notification settings - Fork 0
Feature: rename samples #6
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
Conversation
| # ------------------------------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| class NameMap(dict): |
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.
This class handles parsing sample names from argument lists or files.
| yield FastqFile(source_path, sample_name, read, self.prefix) | ||
| new_name = self.sample_name_map[sample_name] | ||
| yield FastqFile(source_path, new_name, read, self.prefix) |
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.
This is really the only place where the new sample name is used. All the other changes in this file are variable name changes that don't really affect how the code works.
ezfastq/cli.py
Outdated
| epilog_text = """ | ||
| Examples: | ||
| ezfastq /path/to/fastqs/ sample1 sample2 sample3 | ||
| ezfastq /path/to/fastqs/ s1:Sample1 s2:Sample2 s3:Sample3 | ||
| ezfastq /path/to/fastqs/ samplenames.txt | ||
| ezfastq /path/to/fastqs/ samplenames.txt --workdir /path/to/projectdir/ --subdir seq/Run01/ | ||
| ezfastq /path/to/fastqs/ samplenames.txt --pair-mode 2 | ||
| """ | ||
| epilog = Text(epilog_text, no_wrap=True) |
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.
Added an epilog to the argument parser since showing examples is the best way to describe how the sample renaming is done.
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.
This file has unit tests for the new NameMap class.
| def test_copier_with_renaming(tmp_path): | ||
| sample_names = NameMap.from_arglist( | ||
| ["test1:TestSampleA", "test2:TestSampleB", "test3:TestSampleC"] | ||
| ) |
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.
Also added a test for the FastqCopier test to make sure it renames files correctly on copy.
|
This looks great! I've grown to really appreciate instantiating classes with classmethods. It seems to provide a lot more flexibility, i.e. from file or arglist than with one function containing a lot of logic statements. |
This PR adds support for renaming samples in the process of copying. Sample names are current specified one of two ways: as a list of string arguments...
...or as a file containing one sample name for each line.
This update allows sample renaming in both cases. For lists of string arguments, this is done by specifying the old name and new name separated by a colon.
For sample name files, this is done by adding a new column with a tab-separated value.