-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from brain-bican/add_cli_library_generation
Add functionality to parse data catalog's large file metadata manifest
- Loading branch information
Showing
3 changed files
with
50 additions
and
3 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import csv | ||
import click | ||
|
||
def extract_specimen_ids(csv_file_path): | ||
""" | ||
Reads a CSV file and prints the 'Specimen ID' column to the command line. | ||
Parameters: | ||
- csv_file_path: str, path to the input CSV file. | ||
""" | ||
with open(csv_file_path, 'r', encoding='utf-8') as csv_file: | ||
reader = csv.DictReader(csv_file) | ||
|
||
# Ensure 'Specimen ID' column exists in the CSV | ||
if 'Specimen ID' not in reader.fieldnames: | ||
raise ValueError("The CSV file does not contain the 'Specimen ID' column.") | ||
|
||
# Print 'Specimen ID' values to the command line | ||
for row in reader: | ||
specimen_id = row['Specimen ID'] | ||
if specimen_id.startswith("LA"): | ||
print(specimen_id) | ||
|
||
@click.command | ||
@click.argument('specimen_metadata_file_path') | ||
|
||
def list_library_aliquot(specimen_metadata_file_path): | ||
""" | ||
Extracts and prints all the Library Aliquot NHash IDs from Data Catalog's specimen metadata file. | ||
Args: | ||
specimen_metadata_file_path (str): Path to the specimen metadata file. | ||
""" | ||
extract_specimen_ids(specimen_metadata_file_path) | ||
|
||
if __name__ == '__main__': | ||
list_library_aliquot() |