I am in the process of writing up a bash script that runs three bioinformatics tools and then executes a python script. This python script compiles some of the data from the informatics tools output into a single merged output file. Now I need to run this on a large number of samples at a time so I am trying to set up the script to read through the directory path to where all the output from the tools is stored.
These are the directory paths for the python script input files:
EFS/Analyses/BGC.test/Sample_Name/antismash2/sample.LargeContigs.gbk
EFS/Analyses/BGC.test/Sample_Name/Bagel4/00.OverviewGeneTables.json
EFS/Analyses/BGC.test/Sample_Name/Deepbgc/Deepbgc.bgc.tsv
Now there are multiple Sample_Name directories containing identical structures in the EFS/Analyses/BGC.test path. I would like to run the script on all of them
To do this, I have written a for
loop within the bash script as follows:
sample_paths=$(find $EFS/Analyses/BGC.test -mindepth 1 -maxdepth 1 -type d \ )
while read sample_paths;
do
sample=$(basename $sample_paths)
GenBank_Input="$sample/antismash2/$sample.LargeContigs.gbk";
TsvFile_Input="$sample/Deepbgc/Deepbgc.bgc.tsv";
Json_Input="$sample/Bagel4/00.OverviewGeneTables.json";
done <<< “$sample_paths”
export GenBank_Input
export TsvFile_Input
export Json_Input
The goal here being to define the sample path for every sample and then for every sample, looping through to the specific directories of each input file. I then exported the variables and used os.environ from the os package to use them in the python script as such:
#parse gbk input file
for record in SeqIO.parse(os.environ["GenBank_Input"], 'genbank'):
#parse tsv input file
file_handle = open(os.environ["TsvFile_Input"])
#parse json input file
json_data = json.load(open(os.environ["Json_Input"]))
Now the error I get when I run the script is a FileNotFoundError: [Errno 2] No such file or directory: '“”/antismash2/“”.LargeContigs.gbk'
so the error seems pretty clear cut. The issue seems to be with the path that I defined within the while loop variables but as of right now, I have been unable to resolve. I am trying to familiarize myself more with bash scripting as I am still fairly new to it. Any guidance on how I might adjust the code to resolve this and get the script working is much appreciated, thanks!
sample_paths
@Joe_G? $\endgroup$$EFS
? How and where is that defined? Also, note that you have“$sample_paths”
(curly, UTF quotes) instead of"$sample_paths"
(normal ASCII quotes). Finally, are you expecting these variables to be strings or arrays? Bash strings interpreted as python lists? Something else? $\endgroup$