My script creates a manifest document that contains the filepaths of my fastq data for upload into qiime2. The input is a text file of the sample names and a directory that contains the fastq files. I then run the shell file using python ./manifest_single.py --input-dir seqs
. Input text file example:
SRR123456 SRR123457 SRR123458...
Below is my shell file
#!/local/cluster/bin/python3
# assign a variable to the file of interest
file_name = "seq.by.sys_accession.txt"
dir = "/filepath/seqs"
# open the file with a file handle
read_SRR = open(file_name, "r")
# obtain a list of lines in your file
allLines_list = read_SRR.readlines()
# create output file
outFile = "manifest.txt"
read_outFile = open(outFile, "w")
read_outFile.write(f"sample-id\tabsolute-filepath\n")
# loop over the body of data lines until the end of the file
for rawLine in allLines_list:
line = rawLine.strip()
print(f"|{line}|")
with open(outFile, "a") as f:
read_outFile.write(f"{line}\t{dir}/{line}.R1.fastq.gz\n")
outFile.close()
read_SRR.close()
But I keep receiving the error
[name@congo metagenome-analysis]$ python ./manifest_single.py --input-dir seqs
File "./manifest_single.py", line 17
read_outFile.write(f"sample-id\tabsolute-filepath\n")
^
SyntaxError: invalid syntax
I've changed the \t
and \n
with a literal "tab". I've triple checked my input file structure and contents.