我正在尝试创建一个工作流,在该工作流中,我获取一个包含输入文件列表的目录,并通过命令行工具运行它们,并将结果输出到输出目录中。它应该非常简单,而且我已经让它工作了......主要是。
问题在于,无论何时我给它一个输入目录,我都会收到"跳过FILE的错误,该文件不存在,或者无法读取&# 34;即使我100%确定文件存在于我的输入目录中。
但是,如果我稍微修改一下代码,然后将其设置为仅输入文件而不是目录,则脚本会像应该的那样运行并完美地完成。
我的输入文件是gzip压缩文件。
这是脚本:
import argparse
import subprocess
import os
parser = argparse.ArgumentParser(description="A RNAseq pipeline for pair-end data")
parser.add_argument("-i", "--inputDir", help="A input directory containing your gzipped fastq files", required=True)
parser.add_argument("-o", "--outputDir", help="Output directory", required=True)
parser.parse_args()
### Define global variables
args = parser.parse_args()
inputDir = args.inputDir
outputDir = args.outputDir
### Grab all fastq files in input directory
fastq_directory = os.listdir("{}".format(inputDir))
fastq_files = []
for file in fastq_directory:
fastq_files.append(file)
### Run FastQC
for file in fastq_files:
fastqc_command = "fastqc --extract -o {} {}".format(outputDir, file)
subprocess.check_output(['bash', '-c', fastqc_command])
错误:
Skipping 'KO1_R1.fastq.gz' which didn't exist, or couldn't be read
Skipping 'KO1_R2.fastq.gz' which didn't exist, or couldn't be read
Skipping 'KO2_R1.fastq.gz' which didn't exist, or couldn't be read
Skipping 'KO2_R2.fastq.gz' which didn't exist, or couldn't be read
Skipping 'KO3_R1.fastq.gz' which didn't exist, or couldn't be read
Skipping 'KO3_R2.fastq.gz' which didn't exist, or couldn't be read
Skipping 'WT1_R1.fastq.gz' which didn't exist, or couldn't be read
Skipping 'WT1_R2.fastq.gz' which didn't exist, or couldn't be read
Skipping 'WT2_R1.fastq.gz' which didn't exist, or couldn't be read
Skipping 'WT2_R2.fastq.gz' which didn't exist, or couldn't be read
Skipping 'WT3_R1.fastq.gz' which didn't exist, or couldn't be read
Skipping 'WT3_R2.fastq.gz' which didn't exist, or couldn't be read
有什么建议吗?
PS:我知道剧本很糟糕,但我正在学习:)。虽然建议肯定受到欢迎!答案 0 :(得分:2)
尝试更改此内容:
fastq_directory = os.listdir("{}".format(inputDir))
fastq_files = []
for file in fastq_directory:
fastq_files.append(file)
对此:
fastq_directory = os.listdir("{}".format(inputDir))
fastq_files = []
for file in fastq_directory:
fastq_files.append(os.path.join(inputDir, file))
这是因为os.listdir()
只返回文件名,而不是完整路径。