【问题标题】:snakemake samples validation schema for csv filecsv 文件的蛇形样本验证模式
【发布时间】:2021-10-26 11:58:48
【问题描述】:

我有一个包含以下列的示例 csv 文件:

SMFID,Fastq1,Fastq2

我尝试使用以下 yaml 来验证 snakemake 中的架构:

$schema: "https://json-schema.org/draft/2020-12/schema"
description: an entry in the sample sheet
properties:
  SMFID:
    type: string
    description: sample name/identifier
  Fastq1:
    type: string
    description: path to fastq file (first mate)
  Fastq2:
    type: string
    description: path to fastq file (second mate)

required:
  - SMFID
  - Fastq1
  - Fastq2

但我收到以下错误:

WorkflowError:验证的数据类型不受支持。

有没有办法指定输入文件是csv?

【问题讨论】:

标签: jsonschema snakemake


【解决方案1】:

这可以在将 csv 加载到 pandas DataFrame 后使用 snakemake 的 snakemake.utils.validate 函数来完成。

如果您提供的架构保存为your_schema.yaml,并且您有samples.csv

SMFID,Fastq1,Fastq2
my_id,sread1,sread2

然后您可以像这样在Snakefile 中进行验证:

import pandas as pd
from snakemake.utils import validate

samples = pd.read_csv("samples.csv")
validate(samples, "your_schema.yaml")

这进一步描述in the docs

【讨论】:

    【解决方案2】:

    您需要将文件从 CSV 转换为 JSON(或您的评估员支持的与 JSON 兼容的格式)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多