翻译代码 ################### Coords2Link function,mummer out format 2 link ##################### sub Coords2Link { my $coords=shift; my $MinAlnLen=shift; my $syn=shift; open (CS,"$coords") || die "input file can't open $!"; open (OUTSYN,">$syn") || die "input file can't open $!"; <CS>;<CS>;<CS>;<CS>;<CS>; while(<CS>) { chomp ; my @inf=split ; next if ($inf[6]<90); next if ((abs($inf[1]-$inf[0])<$MinAlnLen) && (abs($inf[4]-$inf[3])<$MinAlnLen)); print OUTSYN "$inf[-2]\t$inf[0]\t$inf[1]\t$inf[-1]\t$inf[3]\t$inf[4]\n"; } close OUTSYN; close CS; } if($#ARGV<0) { usage ;exit(1) ; } if (($ARGV[0] eq "Paf2Link") || ($ARGV[0] eq "Paf2Syn" )) { Paf2Link($ARGV[1],$ARGV[2],$ARGV[3]); exit(0); } if (($ARGV[0] eq "Coords2Link") || ($ARGV[0] eq "Coords2Syn") ) { Coords2Link($ARGV[1],$ARGV[2],$ARGV[3]); exit(0); } my $InGenomeA; my $InGenomeB; my $help; my $OutPrefix; my $MinLenA; my $MinLenB; my $BinDir; my $MinAlnLen; my $MappingSoft="mummer"; my $NumThreads=6; my $MappingPara=""; foreach my $k (0..$#ARGV) { if ($ARGV[$k] eq "-MappingPara") { $MappingPara=$ARGV[$k+1]; splice(@ARGV,$k,2); last ; } } GetOptions( "InGenomeA:s"=>\$InGenomeA, "InGenomeB:s"=>\$InGenomeB, "OutPrefix:s"=>\$OutPrefix, "MinLenA:s"=>\$MinLenA, "MinLenB:s"=>\$MinLenB, "BinDir:s"=>\$BinDir, "MinAlnLen:s"=>\$MinAlnLen, "MinAlgLen:s"=>\$MinAlnLen, "MappingBin:s"=>\$MappingSoft, "NumThreads:s"=>\$NumThreads, "help"=>\$help, );
时间: 2024-03-18 12:44:38 浏览: 150
这是一个 Perl 代码,主要是用于将 MUMmer 输出的比对结果转化为链接格式的输出。其中包括两个子程序:Paf2Link 和 Coords2Link。Paf2Link 子程序用于将 PAF 格式的比对结果转化为链接格式的输出,Coords2Link 子程序用于将 coords 格式的比对结果转化为链接格式的输出。该代码还包括一些参数,如 InGenomeA、InGenomeB、OutPrefix、MinLenA、MinLenB、BinDir、MinAlnLen、MappingSoft、NumThreads 等。其中,“-MappingPara”是一个可选参数,用于指定映射参数。代码使用了 GetOptions 函数来处理命令行参数。
相关问题
翻译代码############# new the scripts for alignments ,change format and show the alignments ############ if (($MappingSoft eq "mummer") or ($MappingSoft eq "nucmer")) { #mummer-4.0.0/bin/nucmer --mum --mincluster 500 -t 30 Ref.AAfa RefBB.fa -p OUT #mummer-4.0.0/bin/delta-filter -1 -i 90 -l 2000 OUT.delta > OUT.filter1.delta #mummer-4.0.0/bin/show-coords -c -r OUT.filter1.delta > OUT.filter1.coords if ($MappingPara eq "") {$MappingPara = "--mum --mincluster 500 ";} open (OUTSH,">$OutPrefix.mapping.sh") || die "input file can't open $!"; print OUTSH "$nucmer $MappingPara -t $NumThreads $OutPrefix.A.fa $OutPrefix.B.fa -p $OutPrefix \n"; print OUTSH "$deltaFilter -1 -i 90 -l $MinAlnLen $OutPrefix.delta > $OutPrefix.filter.delta \n"; print OUTSH "$showcoords -c -r $OutPrefix.filter.delta > $OutPrefix.filter.coords\n"; print OUTSH "perl $0 Coords2Link $OutPrefix.filter.coords $MinAlnLen $OutPrefix.link \n"; print OUTSH "$NGenomeSyn -InConf $OutPrefix.conf -OutPut $OutPrefix.svg \n"; close OUTSH; system ("sh $OutPrefix.mapping.sh "); } else { if ($MappingPara eq "") {$MappingPara = " -x asm5 "; } open (OUTSH,">$OutPrefix.mapping.sh") || die "input file can't open $!"; print OUTSH "$minimap2 $MappingPara -t $NumThreads $OutPrefix.B.fa $OutPrefix.A.fa > $OutPrefix.paf \n"; print OUTSH "perl $0 Paf2Link $OutPrefix.paf $MinAlnLen $OutPrefix.link \n"; print OUTSH "$NGenomeSyn -InConf $OutPrefix.conf -OutPut $OutPrefix.svg \n"; close OUTSH ; system ("sh $OutPrefix.mapping.sh "); } print "\tALL done, see the xxx.png . you can optimized drawing by [NGenomeSyn] software\n"; print "\t optimized: [Filter] and [Merge] small syn blocks to big syn block\n\n";
这段代码是一个 Perl 脚本,用于进行基因组比对分析。如果 MappingSoft 变量的值为 "mummer" 或 "nucmer",则执行以下步骤:调用 mummer-4.0.0/bin/nucmer 命令对两个基因组进行比对,并生成 .delta 文件;使用 mummer-4.0.0/bin/delta-filter 命令对 .delta 文件进行过滤,生成 .filter1.delta 文件;使用 mummer-4.0.0/bin/show-coords 命令对 .filter1.delta 文件进行格式转换,生成 .filter1.coords 文件;将 .filter1.coords 文件作为参数调用脚本本身($0)并传递参数 Coords2Link、$MinAlnLen、$OutPrefix.link,生成比对结果的可视化图形;最后使用 NGenomeSyn 软件对比对结果进行优化绘图,并输出 .svg 文件。
如果 MappingSoft 变量的值为其他字符串,则执行以下步骤:调用 minimap2 命令对两个基因组进行比对,并生成 .paf 文件;将 .paf 文件作为参数调用脚本本身($0)并传递参数 Paf2Link、$MinAlnLen、$OutPrefix.link,生成比对结果的可视化图形;最后使用 NGenomeSyn 软件对比对结果进行优化绘图,并输出 .svg 文件。
最后输出提示信息,告知比对分析完成,并生成了对应的可视化图形文件。同时提示用户可以使用 NGenomeSyn 软件对绘图进行优化。
翻译代码#####################Find the relevant software in the systerm######################## my $nucmer="/usr/bin/nucmer"; my $deltaFilter="/usr/bin/delta-filter"; my $showcoords="/usr/bin/show-coords"; my $minimap2="/usr/bin/minimap2"; if (($MappingSoft eq "mummer") or ($MappingSoft eq "nucmer")) { # mummer-4.0.0/bin/nucmer # mummer-4.0.0/bin/delta-filter # mummer-4.0.0/bin/show-coords if ( !(-e $nucmer) ) { $nucmer=`which nucmer 2> /dev/null `;chomp $nucmer; } if ( !(-e $deltaFilter) ) { $deltaFilter=`which delta-filter 2> /dev/null `;chomp $deltaFilter; } if ( !(-e $showcoords) ) { $showcoords=`which show-coords 2> /dev/null `;chomp $showcoords; } if (defined $BinDir) { my $tmp="$BinDir/nucmer"; if (-e $tmp) {$nucmer=$tmp;} $tmp="$BinDir/delta-filter"; if (-e $tmp) {$deltaFilter=$tmp;} $tmp="$BinDir/show-coords"; if (-e $tmp) {$showcoords=$tmp;} } if ( !(-e $showcoords) ) { print "\tCan't find the mummer [show-coords] at \$PATH or \$BinDir\n"; print "\tplease Check at it\n";exit; } if ( !(-e $deltaFilter) ) { print "\tCan't find the mummer [delta-Filter] at \$PATH or \$BinDir\n"; print "\tplease Check at it\n";exit; } if ( !(-e $nucmer) ) { print "\tCan't find the mummer [nucmer] at \$PATH or \$BinDir\n"; print "\tplease Check at it\n";exit; } my $NumVer=`$nucmer -V `; chomp $NumVer ; my @ccc=split /\./,$NumVer; if ($ccc[0] <4 ) { print "found the $nucmer version is $NumVer < 4.0 , we need the 4.0\n"; print "\tplease Check at it\n";exit; } } else { if ( !(-e $minimap2) ) { $minimap2=`which minimap2 2> /dev/null `;chomp $minimap2; } if (defined $BinDir) { my $tmp="$BinDir/minimap2"; if (-e $tmp) {$minimap2=$tmp;} } if ( !(-e $minimap2) ) { print "\tCan't find the [ minimap2 ] at \$PATH or \$BinDir\n"; print "\tplease Check at it\n";exit; } } my $NGenomeSyn="$Bin/../NGenomeSyn"; if ( !(-e $NGenomeSyn) ) { $NGenomeSyn="$Bin/NGenomeSyn"; if ( !(-e $NGenomeSyn) ) { print "\tCan't find the [NGenomeSyn] at [ $Bin/..]\n"; print "\tplease Check at it\n";exit; } }
这是一个 Perl 脚本,用于查找系统中是否已经安装了必需的软件。其中包含了四个路径变量:$nucmer、$deltaFilter、$showcoords 和 $minimap2,分别对应了四个软件。如果变量 $MappingSoft 的值为 "mummer" 或 "nucmer",则需要检查是否已经安装了相应的软件,否则需要检查是否安装了 minimap2 软件。如果在系统中未找到相应的软件,脚本会尝试在 $PATH 或 $BinDir 中查找。如果仍然未找到,则会输出错误信息并退出脚本。此外,脚本还会查找是否存在 NGenomeSyn 文件。
阅读全文