User:Squidonius/userpage/code

use LWP::Simple; my $utils = "http://www.ncbi.nlm.nih.gov/entrez/eutils"; my $db    ="pubmed"; my $query  ="\"directed evolution\""; my $report ="abstract"; my $esearch = "$utils/esearch.fcgi?db=$db&retmax=1&usehistory=y&term=$query"; my $esearch_result = get($esearch);  $esearch_result =~  m|(\d+).*(\d+).*(\S+)|s;  my $Count    = $1; my $QueryKey = $2; my $WebEnv   = $3;  print "$Count articles for $QueryKey\n";  # --- my @pmid=; my @journal=; my @title=; my @abs=; my @date=; my @doi=; my $index=0; #redundant? my @c_evolution=; my @c_rational=; my @c_protein=; my @c_synthetic=; my @c_synbio=; my @c_fluoresc=; my @c_biocat=; my @c_bioethanol=; my @c_thermal=; my @c_enantioselect=; my @c_quantum=; my @c_throughput=; my @c_pathway=; my @c_novel=; my @c_vivo=; my @c_vitro=; my @c_non=; my @c_novel=; my @c_computational=; my @c_ratdes=; my @c_environmental=; my @c_biotechnolog=; my @c_socks=; my @c_cytometry=; my @c_engineer=; my @c_RNA=; my @c_DNA=; my @c_FACS=; my @c_enzym=; my @c_therapeutic=; my @c_sensor=; my @c_na=; my @c_drug=; my @c_polymerase=; my @c_method=; my @c_selection=;   my $temp=""; my $retstart; my $retmax=1; my @content= ; #$Count for($retstart = 0; $retstart < $Count; $retstart += $retmax) { my $efetch = "$utils/efetch.fcgi?rettype=$report&retmode=XML&retstart=$retstart&retmax=$retmax&db=$db&query_key=$QueryKey&WebEnv=$WebEnv"; my $efetch_result = get($efetch); @content= ; @content = split(/\n/, $efetch_result); my $size=@content; $index++; print "#"; for(my $i=0; $i <$size; $i++) 	{ 	chomp($content[$i]);  	if ($content[$i] =~ //) 		{ 		$pmid[$index]=$content[$i]; 		$pmid[$index]=~ s///s; 		$pmid[$index]=~ s/<\/PMID>//s; 		$pmid[$index]=~ s/^\s+//s; 		#print $pmid[$index]; 		}  	if ($content[$i] =~ //) 		{ 		$journal[$index]=$content[$i]; 		$journal[$index]=~ s///s; 		$journal[$index]=~ s/<\/Title>//s; 		$journal[$index]=~ s/^\s+//s; 		#print $journal[$index]; 		}  	if ($content[$i] =~ //) 		{ 		$title[$index]=$content[$i]; 		$title[$index]=~ s///s; 		$title[$index]=~ s/<\/ArticleTitle>//s; 		$title[$index]=~ s/^\s+//s; 		#print $title[$index]; 		}  	if ($content[$i] =~ //) 		{ 		$abs[$index]=$content[$i]; 		$abs[$index]=~ s///s; 		$abs[$index]=~ s/<\/AbstractText>//s; 		$abs[$index]=~ s/^\s+//s; 		#print $abs[$index]; 		}  	if ($content[$i] =~ //) 		{		 		$temp=0; 		$temp=$content[$i]; 		$temp=~ s/^\s+//s; 		$temp=~ s/<\/LastName>//s; 		$author[$index]="$author[$index]\:$temp"; 		}  	if ($content[$i] =~ /<DateCreated>/) 		{ 		$temp=0; 		$temp=$content[$i+3]; 		$temp=~ s/^\s+<Day>//s; 		$temp=~ s/<\/Day>//s; 		$date[$index]="$temp\:"; 		$temp=$content[$i+2]; 		$temp=~ s/^\s+<Month>//s; 		$temp=~ s/<\/Month>//s; 		$date[$index]="$date[$index]$temp\:"; 		$temp=$content[$i+1]; 		$temp=~ s/^\s+<Year>//s; 		$temp=~ s/<\/Year>//s; 		$date[$index]="$date[$index]$temp"; 		}  	if ($content[$i] =~ /<ArticleId IdType\=\"doi\">/) 		{ 		$doi[$index]=$content[$i]; 		$doi[$index]=~ s/^\s+<ArticleId IdType\=\"doi\">//s; 		$doi[$index]=~ s/<\/ArticleId>//s; 		}  	if ($content[$i] =~ /<Affiliation>/) 		{ 		$place[$index]=$content[$i]; 		$place[$index]=~ s/^\s+<Affiliation>//s; 		$place[$index]=~ s/<\/Affiliation>//s; 		}  	if ($abs[$index] =~ m/evolution/i){$c_evolution[$index]="1"}else{$c_evolution[$index]="0"} 	if ($abs[$index] =~ m/rational /i){$c_rational[$index]="1"}else{$c_rational[$index]="0"} 	if ($abs[$index] =~ m/synthe/i){$c_synthetic[$index]="1"}else{$c_synthetic[$index]="0"} 	if ($abs[$index] =~ m/synthetic biology/i){$c_synbio[$index]="1"}else{$c_synbio[$index]="0"} 	if ($abs[$index] =~ m/protein/i){$c_protein[$index]="1"}else{$c_protein[$index]="0"} 	if ($abs[$index] =~ m/fluoresc/i){$c_fluoresc[$index]="1"}else{$c_fluoresc[$index]="0"} 	if ($abs[$index] =~ m/biocatalysis/i){$c_biocat[$index]="1"}else{$c_biocat[$index]="0"} 	if ($abs[$index] =~ m/bioethanol/i){$c_bioethanol[$index]="1"}else{$c_bioethanol[$index]="0"} 	if ($abs[$index] =~ m/therm/i){$c_thermal[$index]="1"}else{$c_thermal[$index]="0"} 	if ($abs[$index] =~ m/enantioselect/i){$c_enantioselect[$index]="1"}else{$c_enantioselect[$index]="0"} 	if ($abs[$index] =~ m/quantum/i){$c_quantum[$index]="1"}else{$c_quantum[$index]="0"} 	if ($abs[$index] =~ m/throughput/i){$c_throughput[$index]="1"}else{$c_throughput[$index]="0"} 	if ($abs[$index] =~ m/pathway/i){$c_pathway[$index]="1"}else{$c_pathway[$index]="0"} 	if ($abs[$index] =~ m/novel/i){$c_novel[$index]="1"}else{$c_novel[$index]="0"} 	if ($abs[$index] =~ m/vivo/i){$c_vivo[$index]="1"}else{$c_vivo[$index]="0"} 	if ($abs[$index] =~ m/vitro/i){$c_vitro[$index]="1"}else{$c_vitro[$index]="0"} 	if ($abs[$index] =~ m/non-natural/i){$c_non[$index]="1"}else{$c_non[$index]="0"} 	if ($abs[$index] =~ m/ novel /i){$c_novel[$index]="1"}else{$c_con[$index]="0"} 	if ($abs[$index] =~ m/computational/i){$c_computational[$index]="1"}else{$c_computational[$index]="0"} 	if ($abs[$index] =~ m/rational design/i){$c_ratdes[$index]="1"}else{$c_ratdes[$index]="0"} 	if ($abs[$index] =~ m/environmental/i){$c_environmental[$index]="1"}else{$c_environmental[$index]="0"} 	if ($abs[$index] =~ m/socks/i){$c_socks[$index]="1"}else{$c_socks[$index]="0"} 	if ($abs[$index] =~ m/biotechnolog/i){$c_biotechnolog[$index]="1"}else{$c_biotechnolog[$index]="0"} 	if ($abs[$index] =~ m/cytometry/i){$c_cytometry[$index]="1"}else{$c_cytometry[$index]="0"} 	if ($abs[$index] =~ m/engineer/i){$c_Engineer[$index]="1"}else{$c_engineer[$index]="0"} 	if ($abs[$index] =~ m/RNA/i){$c_RNA[$index]="1"}else{$c_RNA[$index]="0"} 	if ($abs[$index] =~ m/DNA/i){$c_DNA[$index]="1"}else{$c_DNA[$index]="0"} 	if ($abs[$index] =~ m/FACS/i){$c_FACS[$index]="1"}else{$c_FACS[$index]="0"} 	if ($abs[$index] =~ m/enzym/i){$c_enzym[$index]="1"}else{$c_enzym[$index]="0"} 	if ($abs[$index] =~ m/therapeutic/i){$c_therapeutic[$index]="1"}else{$c_therapeutic[$index]="0"} 	if ($abs[$index] =~ m/sensor/i){$c_sensor[$index]="1"}else{$c_sensor[$index]="0"} 	if ($abs[$index] =~ m/nucleic acid/i){$c_na[$index]="1"}else{$c_na[$index]="0"} 	if ($abs[$index] =~ m/drug/i){$c_drug[$index]="1"}else{$c_drug[$index]="0"} 	if ($abs[$index] =~ m/polymerase/i){$c_polymerase[$index]="1"}else{$c_polymerase[$index]="0"} 	if ($abs[$index] =~ m/method/i){$c_method[$index]="1"}else{$c_method[$index]="0"} 	if ($abs[$index] =~ m/selection/i){$c_selection[$index]="1"}else{$c_selection[$index]="0"} 	   	}   }  open(OUT,'>final.txt') or die "Can't make file: $!"; print OUT "$query\n"; for(my $j=1; $j <$index; $j++) 	{ 	print OUT "$j:\t$pmid[$j]\t$title[$j]\t$journal[$j]\t$abs[$j]\t$date[$j]\t$author[$j]\t$doi[$j]\t$c_evolution[$j]\t$c_rational[$j]\t$c_protein[$j]\t$@c_[$j]\t$@c_[$j]\t$@c_[$j]\t$c_synthetic[$j]\t$c_synbio[$j]\t$c_fluoresc[$j]\t$c_biocat[$j]\t$c_bioethanol[$j]\t$c_thermal[$j]\t$c_enantioselect[$j]\t$c_quantum[$j]\t$c_throughput[$j]\t$c_pathway[$j]\t$c_novel[$j]\t$c_vivo[$j]\t$c_vitro[$j]\t$c_non[$j]\t$c_novel[$j]\t$c_computational[$j]\t$c_ratdes[$j]\t$c_environmental[$j]\t$c_biotechnolog[$j]\t$c_socks[$j]\t$c_cytometry[$j]\t$c_engineer[$j]\t$c_RNA[$j]\t$c_DNA[$j]\t$c_FACS[$j]\t$c_enzym[$j]\t$c_therapeutic[$j]\t$c_sensor[$j]\t$c_na[$j]\t$c_drug[$j]\t$c_polymerase[$j]\t$c_method[$j]\t$c_selection[$j]\n";}   my @pmid=; my @journal=; my @title=; my @abs=; my @date=; my @doi=;  print "\ndone\a";