2015-06-20 27 views
2

这是制表符分隔的文件:转换制表符分隔文本文件转换成HTML/PDF /乳胶/ knitr报告

 
Chr Start End Ref Alt Func.refGene Gene.refGene GeneDetail.refGene ExonicFunc.refGene AAChange.refGene snp138 clinvar_20140929 SIFT_score SIFT_pred Polyphen2_HDIV_score Polyphen2_HDIV_pred Polyphen2_HVAR_score Polyphen2_HVAR_pred LRT_score LRT_pred MutationTaster_score MutationTaster_pred MutationAssessor_score MutationAssessor_pred FATHMM_score FATHMM_pred RadialSVM_score RadialSVM_pred LR_score LR_pred VEST3_score CADD_raw CADD_phred GERP++_RS phyloP46way_placental phyloP100way_vertebrate SiPhy_29way_logOdds 
chr13 52523808 52523808 C T exonic ATP7B  nonsynonymous SNV ATP7B:NM_000053:exon12:c.2855G>A:p.R952K,ATP7B:NM_001243182:exon13:c.2522G>A:p.R841K rs732774 CLINSIG=non-pathogenic|non-pathogenic;CLNDBN=Wilson's_disease|not_specified;CLNREVSTAT=single|single;CLNACC=RCV000029357.1|RCV000078044.1;CLNDSDB=GeneReviews:MedGen:OMIM:Orphanet:SNOMED_CT|.;CLNDSDBID=NBK1512:C0019202:277900:ORPHA905:88518009|. 0.99 T 0.04 B 0.03 B 0.000 N 0.000 P -1.04 N -3.73 D -0.965 T 0.000 T 0.214 1.511 11.00 6.06 1.111 2.781 12.356 
chr13 52523867 52523867 T G exonic ATP7B  synonymous SNV ATP7B:NM_000053:exon12:c.2796A>C:p.S932S,ATP7B:NM_001243182:exon13:c.2463A>C:p.S821S                            

我有一个bash脚本,它ABI文件作为输入,并使用ANNOVAR的注解变种。制作一个制表符分隔的文本文件,其中包含注释的变体。因此,每次对不同的ABI文件执行bash脚本时,列的数量都固定在制表符分隔的文件中,但行数以及单个注释可能因每个结果变体而异。

尝试迄今为止 - >

我试图写提取[第一个变种]从制表符分隔文本文件不同的领域,其保存为文本文件bash脚本,将所有产生的文本单个文件,并使用AWK脚本将不同的变量分配给组合文本文件中的每个字段。我使用AWK创建了HTML页面,并使用AWK脚本中的这些变量在HTML中的相应标记中进行打印,并且它对于在制表符分隔的文本文件中遵循相同模式的文件工作良好。但是,如果特定字段不存在其他具有不同模式的注释结果,则该脚本将输出与其分配的变量不同的字段。

如果第一个变体包含临床显着变异,则会在“clinvar”列中出现注释,因此需要将其与其他详细信息一起报告在不同的部分。

组合文本文件的顺序对于每个变体都不相同,因此为其生成的报告不正确。

预期结果 - >

由于制表符分隔的文件的格式是不均匀的,是没有什么办法,对每一行我可以设置多个条件,其中例如如果一个特定的柱[用于例如: clinvar]有一个值,然后将它打印在HTML标签之间,如果不存在,则检查另一列[例如:rsID],如果存在值,则将其打印到其他HTML标签中,以此类推其他专栏也是如此!

变位置:CHR 13:52523808C>Ť

VARIANT类型:非同义-SNV

RSID:rs732774

氨基酸变化:p.R952K

基因名称:ATP7B

疾病:肝豆状核变性

结果:非致病性

HTML页面的格式和它的值应该是这样的:

<html> 
<title></title><head> 
<style type="text/css"> 
body {background-color:lightgray} 
h1 {background-color:SlateGray} 
</style> 
</head><body bgcolor="LightGray"> 
<table border=1><th align=>Test Code</th><th align=>Gene Name</th><th align=>Condition tested</th><th align=>Result</th> 
<tr><td width=750 align=></td><td width=750 align=>ATP7B(RefSeq ID: NM_000053)</td><td width=750 align=>Wilson's_disease</td><td width=750 align=>Non-pathogenic</td></tr> 
<h1 align=>Test Details</h1> 
<table border=1><th align=centre>Genomic Location of Mutation</th><th align=centre>Mutation Type</th><th align=centre>dbSNP Identifier</th><th align=centre>Amino Acid Change</th><th align=centre>OMIM Identifier</th> 
<h1 align=>Significant Findings</h1> 
<tr><td width=750 align=>chr13:52523808C>T</td><td width=750 align=>Nonsynonymous-SNV</td><td width=750 align=>rs732774</td><td width=750 align=>p.R952K</td><td width=750 align=>http://www.omim.org/entry/277900</td></tr> 
<p> The identified variant is located in the <strong> exonic </strong> region of the <strong> chr13 </strong> chromosome and is a <strong> Nonsynonymous-SNV </strong> which causes an amino acid change from <strong> Arginine </strong> to <strong> Lysine </strong>. The mutation has also been reported in the dbSNP database (http://www.ncbi.nlm.nih.gov/SNP/) with an accession number of <strong> rs732774 </strong>. </p> 
</table></body> 
</html> 

以类似的方式,当存在新型变体时,其中ExonicFunc。refGene列包含“非同义词”,并且在snp138列中没有值,则应该在HTML标签之间打印SIFT_score以及其他详细信息。这些只是需要的一些条件,但如果任何人都可以给出一个关于如何解决这一切的想法,那将非常有帮助!

感谢您阅读这样一个长期的问题,任何有关这个问题的帮助将不胜感激。

+3

我的标签分隔文本中没有看到任何TAB。请显示一些示例输入和相应的输出。 –

回答

0

我在这里展示的awk程序拆分了相应行中的所有标题和所有数据。我认为你可以修改它来定制你的需求。请记住,你所拥有的所有棘手的规则 - 当没有出现时,表明相反 - 最好是自己实施而不是要求实施。

# 
# processor.awk 
# 


BEGIN { 
     IGNORECASE = 1; 
     header = ""; 
     html_template = "<tr><td>##fieldname</td><td>##fieldvalue</td></tr>" 
     } 
     { 
     if(header == "" && $0 != "") 
     { # the first not empty line is the header 
      header = $0; 
      # put every element of the header into an array 
      split(header, fields, "\t"); 
      # for debug: print the fields found 
      #for(elem in fields) 
      # print "field" elem ": " fields[elem]; 
     } # if 
     else 
     { 
      # normal lines 
      # split the line into the elements 
      split($0, content, "\t"); 
      # for every element in the content line.... 
      for(elem = 1; fields[elem] !=""; elem++) 
      { 
       print elem; 
       out_line = html_template; 
       out_line = gensub(/##fieldname/, fields[elem], "g", out_line); 
       out_line = gensub(/##fieldvalue/, content[elem], "g", out_line); 
       # print the result 
       print out_line; 
      } # for 
     } # if 
     } 
END  { 
     } 
相关问题