-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
519 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ node_modules | |
# python | ||
.venv/ | ||
venv | ||
|
||
catalog-schema/docs |
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,84 @@ | ||
import pandas as pd | ||
import os | ||
|
||
|
||
def process_alignments(): | ||
""" | ||
Reads 'source/alignments.csv', processes columns including 'version', 'reference_coordinates', | ||
and adds an 'alignment' column. Special cases: | ||
- If 'pipeline' is 'minigraph-cactus', use 'mc' instead of the pipeline name in 'alignment'. | ||
- Skip determining 'reference_coordinates' if the file name contains 'all'. | ||
Writes the result to 'source/alignments2.csv'. | ||
""" | ||
# Define the directory and file paths | ||
directory = "source" | ||
input_file = os.path.join(directory, "alignments.csv") | ||
output_file = os.path.join(directory, "alignments2.csv") | ||
|
||
try: | ||
# Read the alignments file into a DataFrame | ||
df = pd.read_csv(input_file) | ||
|
||
# Ensure the necessary columns exist | ||
if "file" not in df.columns: | ||
raise ValueError("The input file must have a 'file' column.") | ||
if "pipeline" not in df.columns: | ||
raise ValueError("The input file must have a 'pipeline' column.") | ||
if "reference_coordinates" not in df.columns: | ||
# If the 'reference_coordinates' column doesn't exist, add it | ||
df["reference_coordinates"] = "" | ||
|
||
# Define a function to determine the version | ||
def determine_version(file_name): | ||
if "v1.0" in file_name: | ||
return "v1.0" | ||
elif "v1.1" in file_name: | ||
return "v1.1" | ||
else: | ||
return "" | ||
|
||
# Define a function to extract reference coordinates from the file name | ||
def extract_reference_coordinates(file_name): | ||
if "all" in file_name.lower(): | ||
return "" # Skip if 'all' is in the file name | ||
if "chm13" in file_name: | ||
return "chm13" | ||
elif "grch38" in file_name: | ||
return "grch38" | ||
else: | ||
return "" | ||
|
||
# Add the 'version' column | ||
df["version"] = df["file"].apply(determine_version) | ||
|
||
# Update 'reference_coordinates' where 'pipeline' is 'pggb' and 'all' is not in the file name | ||
df.loc[df["pipeline"] == "pggb", "reference_coordinates"] = df.loc[ | ||
df["pipeline"] == "pggb", "file" | ||
].apply(extract_reference_coordinates) | ||
|
||
# Define a function to build the 'alignment' column | ||
def build_alignment(row): | ||
# Use 'mc' instead of 'minigraph-cactus' for the pipeline | ||
pipeline_value = ( | ||
"mc" if row["pipeline"] == "minigraph-cactus" else row["pipeline"] | ||
) | ||
base = f"hprc-{row['version']}-{pipeline_value}" | ||
if row["reference_coordinates"]: | ||
return f"{base}-{row['reference_coordinates']}" | ||
return base | ||
|
||
# Add the 'alignment' column | ||
df["alignment"] = df.apply(build_alignment, axis=1) | ||
|
||
# Write the updated DataFrame to the output file | ||
df.to_csv(output_file, index=False) | ||
print(f"Processed file successfully written to '{output_file}'") | ||
except FileNotFoundError: | ||
print(f"Error: The input file '{input_file}' was not found.") | ||
except Exception as e: | ||
print(f"An error occurred: {e}") | ||
|
||
|
||
# Run the function | ||
if __name__ == "__main__": | ||
process_alignments() |
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,58 @@ | ||
Field,HPRC_HiC.tsv,HPRC_ONT.tsv,HPRC_PacBio_HiFi.tsv | ||
data_type,x,x,x | ||
design_description,x,x,x | ||
filename,x,x,x | ||
generator_contact,x,x,x | ||
generator_facility,x,x,x | ||
instrument_model,x,x,x | ||
library_ID,x,x,x | ||
library_layout,x,x,x | ||
library_selection,x,x,x | ||
library_source,x,x,x | ||
library_strategy,x,x,x | ||
path,x,x,x | ||
platform,x,x,x | ||
shear_method,x,x,x | ||
total_Gbp,x,x,x | ||
N50,,x,x | ||
accession,x,,x | ||
biosample_accession,x,,x | ||
coverage,x,x, | ||
filetype,x,x, | ||
notes,,x,x | ||
ntsm_score,x,x, | ||
sample_ID,,x,x | ||
size_selection,,x,x | ||
study,x,,x | ||
total_bp,x,,x | ||
100kb+,,x, | ||
1Mb+,,x, | ||
200kb+,,x, | ||
300kb+,,x, | ||
400kb+,,x, | ||
500kb+,,x, | ||
DeepConsensus_version,,,x | ||
MM_tag,,,x | ||
N25,,,x | ||
N75,,,x | ||
assembly,x,, | ||
basecaller,,x, | ||
basecaller_model,,x, | ||
basecaller_version,,x, | ||
bioproject_accession,x,, | ||
ccs_algorithm,,,x | ||
max,,,x | ||
mean,,,x | ||
min,,,x | ||
ntsm_result,x,, | ||
polymerase_version,,,x | ||
quartile_25,,,x | ||
quartile_50,,,x | ||
quartile_75,,,x | ||
result,,x, | ||
sample_id,x,, | ||
seq_kit,,x, | ||
seq_plate_chemistry_version,,,x | ||
title,x,, | ||
total_reads,,,x | ||
whales,,x, |
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 @@ | ||
docs/* |
Oops, something went wrong.