Snakemake:os.listdir()列出不存在的文件

2024-10-01 07:34:02 发布

您现在位置:Python中文网/ 问答频道 /正文

编辑:

我首先调用conda activate snakemake


我的Snakefile包含以下内容:

configfile: "config.yaml"

rule all:
 input: expand("{root_dir}/{geoid}/*.CEL", root_dir = config['root_dir'], geoid = config['geoid'])

rule getCelFiles:
 output: "{root_dir}/{geoid}/*.CEL"
 run:
  if not os.path.exists(os.path.join(wildcards.root_dir,wildcards.geoid)) :
   shell("Rscript scripts/getCELFiles.R {wildcards.geoid} "
         "cd {wildcards.geoid} && tar -xvf * && rm *.tar && gunzip *")
  else :
   print(os.listdir())
   print("getcwd:", os.getcwd())
   print(os.path.exists(os.path.join(wildcards.root_dir,wildcards.geoid)))
   print(os.path.join(wildcards.root_dir,wildcards.geoid))

当我在当前目录中运行ls时,我得到以下输出:

config.yaml  old  README.txt  scripts  Snakefile

但是else条件的输出返回以下内容:

os.listdir(): 
['.snakemake', 'Snakefile', 'README.txt', 'scripts', '.DS_Store', 'old', 'GSE4290', 'config.yaml']

getcwd: 
/home/rebecca/workflows/exploring_tools/affymetrix_preprocess/snakemake # current working directory 

os.path.exists: True

os.path.join: 
/home/rebecca/workflows/exploring_tools/affymetrix_preprocess/snakemake/GSE4290 # directory that is being checked for

那里似乎有一些文件/文件夹,即GSE4290,它们“实际上”并不在那里。我想知道snakemake是否在某个“并行”环境中运行run指令?基本上,我不知道如何使用GSE4290文件夹,使代码按预期运行(即使用Rscript命令运行块,等等)

提前谢谢


Tags: pathconfigyamlosdirexistsscriptsroot