Mykrobe预测器JSON到TSV转换器

时间:2016-10-04 08:51:40

标签: python json linux bioinformatics

我想问一个关于文件转换的问题。

我有一个JSON文件(在AMR预测执行之后)我想要基于Mykrobe-predictor脚本(json_to_tsv.py)转换为TSV文件,这是我的JSON输出(result_TB.json)。

./json_to_tsv.py /path/to/JSON_file

当我将命令粘贴到终端时,我在第78行得到了一个IndexError。

https://github.com/iqbal-lab/Mykrobe-predictor/blob/master/scripts/json_to_tsv.py#L78

 def get_sample_name(f):
  return f.split('/')[-2]

这是我得到的错误:

mykrobe_version file plate_name sample drug phylo_group species lineage phylo_group_per_covg species_per_covg lineage_per_covg phylo_group_depth species_depth lineage_depth susceptibility variants (gene:alt_depth:wt_depth:conf) genes (prot_mut-ref_mut:percent_covg:depth)
  Traceback (most recent call last):
  File "./json_to_tsv.py", line 157, in <module>
  sample_name = get_sample_name(f)
  File "./json_to_tsv.py", line 78, in get_sample_name
  return f.split('/')[-2]
  IndexError: list index out of range

任何建议都将不胜感激。

1 个答案:

答案 0 :(得分:0)

查看代码,我猜他们希望用以下代码调用转换器:

python json_to_tsv.py plate/sample1/sample1.json

尝试将JSON文件复制到名为sample1的目录中名为plate的目录中,并查看在调用它时是否收到相同的错误,如上例所示。

<强>更新

问题确实如上所述。

不起作用:

python json_to_tsv.py result_TB.json 
  

mykrobe_version文件plate_name样本药物phylo_group物种谱系phylo_group_per_covg species_per_covg lineage_per_covg phylo_group_depth species_depth lineage_depth易感性变体   (基因:alt_depth:wt_depth:conf)基因   (prot_mut-ref_mut:percent_covg:depth)

Traceback (most recent call last):   File "json_to_tsv.py", line 157, in <module>
    sample_name = get_sample_name(f)   File "json_to_tsv.py", line 78, in get_sample_name
    return f.split('/')[-2] IndexError: list index out of range

<强>使用:

python json_to_tsv.py plate/sample/result_TB.json 
  

mykrobe_version文件plate_name样本药物phylo_group物种谱系phylo_group_per_covg species_per_covg lineage_per_covg phylo_group_depth species_depth lineage_depth易感性变体(基因:alt_depth:wt_depth:conf)基因(prot_mut-ref_mut:percent_covg:depth)

     

-1 result_TB平板样本NA