forked from TheJacksonLaboratory/splicing-pipelines-nf
-
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.
add process to filter manifest by file passed through --reads
- Loading branch information
Showing
3 changed files
with
63 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import sys | ||
import shutil | ||
import pandas as pd | ||
|
||
def __main__(): | ||
|
||
manifest = sys.argv[1] | ||
reads = sys.argv[2] | ||
print("Input manifest file:", manifest) | ||
print("Input read file: ", reads) | ||
|
||
manifest_df = pd.read_csv(manifest, index_col=None, header=0, delimiter=",") | ||
|
||
if reads != "PASS": | ||
# process metadata | ||
reads_df = pd.read_csv(reads, index_col=None, header=0, delimiter=",") | ||
manifest_df = manifest_df[manifest_df['file_name'].isin(reads_df['file_name'].tolist())] | ||
|
||
if manifest_df.empty: | ||
sys.exit(404, "Manifest file is empty after filtering.") | ||
|
||
if len(reads_df[~reads_df['file_name'].isin([manifest_df['file_name'].tolist()])])>0: | ||
print("The following file_name IDs where not found in manifest:") | ||
print(reads_df[~reads_df['file_name'].isin([manifest_df['file_name'].tolist()])]) | ||
reads_df[~reads_df['file_name'].isin([manifest_df['file_name'].tolist()])].to_csv("not_found_GTEX_samples.txt", index=False) | ||
|
||
# save final manifest file | ||
manifest_df.to_csv("filtered_manifest.csv", sep=",", index=False) | ||
|
||
if __name__=="__main__": __main__() |
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