您好,登錄后才能下訂單哦!
indel vcf文件如何轉化為SNPT輸入文件,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
如何將indel vcf文件轉換為SNPT軟件的輸入文件。
SNP指紋圖譜軟件SNPT ,這里記錄一下如何將indel vcf文件轉換為SNPT軟件的輸入文件。
命令如下:
perl /share/work/wangq/script/vcf/vcf_SNPT.indel.pl -vcf clean.vcf -o SNPT.input.txt
vcf_SNPT.indel.pl腳本如下:
#!/share/nas2/genome/bin/perl -w #use strict; #use warnings; use Getopt::Long; use List::Util qw(shuffle); use Data::Dumper; use FindBin qw($Bin $Script); use File::Basename qw(basename dirname); use Cwd qw(abs_path); my $version="1.0.0"; my $BEGIN_TIME=time(); my @Original_ARGV=@ARGV; # ============================================================== # Get Options # ============================================================== my ($infile, $indexOut, $p); GetOptions( "help|?" =>\&USAGE, "vcf:s"=>\$infile, "o:s"=>\$out ) or &USAGE; &USAGE unless ($infile and $out); sub USAGE {# my $usage=<<"USAGE"; Program: $0 Version: $version ================================================================================================== Discription: This script is used to calculate thresold for BSA using SNP-INDEX method ================================================================================================== Usage: Options: -vcf <str> required vcf list file -o <str> required output file USAGE print $usage; exit; } #=============================================================== # Default optional value #=============================================================== open (IN, "<$infile") || die "$infile: $!\n"; open (OUT, ">$out") || die "$out: $!\n"; my @sample; my %snp; my @indel; while(<IN>){ chomp; next if(/^##/); my ($chr,$pos,$id,$ref,$alt,$qual,$filter,$info,$format,@line) = split(/\t/,$_); if(/^#/){ @sample = @line; next; } my @array = $_=~/\t([\.0123][\/\|][\.0123])/g; if(@array != @sample ){ print "SNP $chr,$pos length not eq.\n"; next; } my $chr_indel= "$chr-$pos"; push(@indel,$chr_indel); for(my$i =0; $i<@line ;$i++){ my $str; if($array[$i] eq "0/0" || $array[$i] eq "0|0" ){ $str = "A"; }elsif($array[$i] eq "0/1" || $array[$i] eq "0|1" ){ $str = "C"; }elsif($array[$i] eq "1/1" || $array[$i] eq "1|1" ){ $str = "G"; }else{ $str = "T"; } $snp{$chr_indel}{$sample[$i]} = $str; } } close(IN); print OUT join("\t","Strain",@indel)."\t"; for($i=0; $i < @sample ; $i++){ print OUT "$sample[$i]"; for($j=0; $j < @indel ; $j++){ #print "1"; print OUT "\t$snp{$indel[$j]}{$sample[$i]}"; } print OUT "\n"; } close(OUT);
關于indel vcf文件如何轉化為SNPT輸入文件問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。