⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 converttolatex.pl

📁 比对算法的具体应用DNA序列分析 ——基因序列 ——基因表达调控信息 寻找基因牵涉到两个方面的工作 : 识别与基因相关的特殊序列信号 预测基因的编码区域 结合两个方面的结果确定基因的位置和结构 基因表
💻 PL
字号:
# perl script to convert genExpDocs readme files to a reasonable latex format# they will probably still need cleaning up afterwards...use strict;$#ARGV==1 or die " \n\nperl convertToLatex.pl D:\\pathToGenExpDocsDir D:\\pathToGenExpDocsTex\n\n";my @docFiles = glob($ARGV[0]."\\*.txt");my $outDir = $ARGV[1]."\\";foreach (@docFiles){	# get filename	my $outf = "tmp";	if(/([\w]+)\.txt$/)	{		$outf = $outDir . $1 . ".tex";	}	# read in every line, and if it is special in some way, do something to it!	open IN, $_;	my $tex = "";	$/ = "---";	my $count = 0;	my $secCount=0;	while(<IN>)	{		# crop the --- off the end		chomp; chomp; chomp;		# replace any non latex characters		s/\\/\$\\backslash\$/g;  # backslash		s/_/\\_/g;               # underscore		s/ '/ `/g;               # opening quote		if($count==1)		{			# This is the section header			my @words = split(/ +/);			$tex .= "\n\\section{";			foreach my $w (@words)			{				$w = lc($w);				$tex .= ucfirst($w)." ";			}			$tex .= "}\n";		}		elsif($count>1)		{			if(!/\n/)			{				# this must be a main list item				$tex .= "\n\\subsection{";				/(.*)/;				/^[^\)]+\) +(.*)/;				$tex .= "$1}\n";			}			else			{				# this is the bulk of a section				if($secCount==1 || $secCount==4)				{					# split by lines					my @lines = split(/\n/);					my $list = 0;					my $openBracket=0;					my $listType = "";					foreach my $line (@lines)					{						# strip all leading and trailing spaces						$line =~ s/^[\s]+//;						$line =~ s/[\s]+$//;						# if a ) comes before a ) this is a list						if($line=~/^([^(]+)\)(.*)/)						{							my $num = $1;							my $rest = $2;														if($openBracket)							{								$openBracket=0;								$tex .= "$line";																if(!$list){ $tex .= "\n"; }							}							else							{								if($list == 0) 								{									#$tex .= "BEGIN LIST\n";									# work out what type of list this is									$num = ($num =~ /[\s]+(.*)/);									if (length($num)==1 || $num=~/^\d+$/)									{										# just make it a normal enumerate										$listType = "enumerate";										$tex .= "\n\\begin{$listType}\n";										$tex .= "\n\t\\item\n";										$tex .= "\t\t$rest ";									}									else									{										# just make it a normal enumerate										$listType = "enumerate";										$tex .= "\n\\begin{$listType}\n";										$tex .= "\n\t\\item\n";										$tex .= "\t\t$rest ";																			}								}								else 								{									$tex .= "\n\t\\item\n";									$tex .= "\t\t$rest ";									#$tex .= "CONTINUE LIST\n";								}									$list = 1;							}						}						elsif ($line=~/^[\s]*$/) 						{							if($list > 0)							{								$list = 2;							}							else							{ 								if(!($tex=~/noindent $/))								{									$tex .= "$line\n\\noindent ";								}															}						}						else						{							# really have found a normal line							if($list == 2)							{								#$tex .= "END LIST\n";								$tex .= "\n\\end{$listType}\n";								$list = 0;							}							$tex .= "$line";							if(!$list){$tex.="\n";}						}						if($line=~/\([^)]+$/)						{							$openBracket=1;						}					}					if($list)					{						$tex .= "\n\\end{$listType}\n";						$list = 0;						#$tex .= "END LIST\n";											}										# first section, leave exactly as it is					#$tex .= "$_\n";				}				elsif($secCount==2)				{					# build up a descriptive list					# split by lines					my @lines = split(/\n/);					my $list = 0;					my $listType = "description";					$tex .= "\n\t\\begin{$listType}";					my $itemCount=0;					foreach my $line (@lines)					{						# strip all leading and trailing spaces						my $lineLength = length($line);						$line =~ s/^[\s]+//;						my $spaceCount = $lineLength - length($line);						$line =~ s/[\s]+$//;						# if a ) comes before a ) this is a list						if($spaceCount < 5 && $line=~/^(.+\w)\s\s+(.*)/)						{							my $setting = $1;							my $description = $2;							$tex .= "\n\t\t\\item{\\emph{$setting}} $description ";							$itemCount++;						}						else						{							if($itemCount==0 && length($line)>0)							{								$tex .= "\n\t\t\\item{\\emph{$line}} ";														}							else							{								$tex .= "$line ";							}						}					}					$tex .= "\n\t\\end{$listType}\n";				}				elsif($secCount==3) # user interface				{					# build up a descriptive list					# split by lines					my @lines = split(/\n/);					my $list = 0;					my $listType = "description";					$tex .= "\n\t\\begin{$listType}";					my $itemCount=0;					my @listItems = ();					my @listDescriptions = ();					foreach my $line (@lines)					{						# strip all leading and trailing spaces						my $lineLength = length($line);						$line =~ s/^[\s]+//;						my $spaceCount = $lineLength - length($line);						$line =~ s/[\s]+$//;						if(($spaceCount < 3) && length($line)>0)						{							if($line=~/(.*) - (.*)/)							{								#print "push 1 ";								my $setting = $1;								my $description = $2;								push(@listItems, $setting);								push(@listDescriptions, $description."\n");							}							elsif($line=~/(.*):(.*)/)							{								#print "push 2 ";								my $setting = $1;								my $description = $2;								push(@listItems, $setting);								push(@listDescriptions, $description."\n");							}							else							{								#print "push 3 ";								push(@listItems, $line);								push(@listDescriptions, "");							}							$itemCount++;						}						elsif(length($line)>0)						{							if($itemCount==0)							{								#print "push 4 ";								push(@listItems, $line);								push(@listDescriptions, "");								$itemCount++;							}							else							{								#print "push 5 ";								my $desc = pop(@listDescriptions);								$desc .= "$line\n";								push(@listDescriptions, $desc);															}						}					}					for(my $i=0; $i<=$#listItems;$i++)					{						$tex .= "\n\t\t\\item{\\emph{$listItems[$i]}}";						if(length($listDescriptions[$i])>0)						{							$tex.="\\\\";							# check for inner lists...							# split by lines							my @lines = split(/\n/, $listDescriptions[$i]);							my $list = 0;							my $openBracket=0;							my $listType2 = "";							foreach my $line (@lines)							{								# strip all leading and trailing spaces								$line =~ s/^[\s]+//;								$line =~ s/[\s]+$//;								# if a ) comes before a ) this is a list								if($line=~/^([^(]+)\)(.*)/)								{									my $num = $1;									my $rest = $2;									if($openBracket)									{										$openBracket=0;										$tex .= "$line";																		if(!$list){ $tex .= "\n"; }									}									else									{										if($list == 0) 										{											#$tex .= "BEGIN LIST\n";											# work out what type of list this is											$num = ($num =~ /[\s]+(.*)/);											if (length($num)==1 || $num=~/^\d+$/)											{												# just make it a normal enumerate												$listType2 = "itemize";												$tex .= "\n\\begin{$listType2}\n";												$tex .= "\n\t\\item\n";												$tex .= "\t\t$rest ";											}											else											{												# just make it a normal enumerate												$listType2 = "itemize";												$tex .= "\n\\begin{$listType2}\n";												$tex .= "\n\t\\item\n";												$tex .= "\t\t$rest ";																					}										}										else 										{											$tex .= "\n\t\\item\n";											$tex .= "\t\t$rest ";											#$tex .= "CONTINUE LIST\n";										}											$list = 1;									}								}								elsif ($line=~/^[\s]*$/) 								{									if($list == 1)									{										$list = 2;									}									$tex .= "$line";								}								else								{									# really have found a normal line									if($list == 2)									{										#$tex .= "END LIST\n";										$tex .= "\n\\end{$listType2}\n";										$list = 0;									}									$tex .= "$line";									if(!$list){$tex.="\n";}								}								if($line=~/\([^)]+$/)								{									$openBracket=1;								}							}							if($list)							{								$tex .= "\n\\end{$listType2}\n";								$list = 0;								#$tex .= "END LIST\n";													}																												#$tex .= "\\\\$listDescriptions[$i]";						}					}					$tex .= "\n\t\\end{$listType}\n";				}													$secCount++;			}			}		$count++;	}	open OUT, ">$outf";	print OUT $tex;	print $outf . "\n";	close OUT;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -