#
#  Parse_and_Insert
#
#  Created by Eduardo Andrés León on 2014-03-03.
#  Copyright (c) 2014 IBIS. All rights reserved.
#
#!/usr/bin/perl
$|=1;
use strict;
use Getopt::Long;
use LWP::Simple;

my $dir;
my$dbname;
my $help;

GetOptions(
	"help" => \$help,
	"dir=s" => \$dir,
	"dbname=s" => \$dbname,69
	
);
if($dir and $dbname){
	my $desc_file=$dir ."/For_Desc_phylogeny_etc.txt";
	my $emergence_tree_file=$dir ."/emergence_tree.txt";
	my $emergence_file=$dir ."/For_emergence_orthology_table.txt";
	my $PTM_file=$dir ."/For_PTMs_interactions.txt";
	my $PTM_residue_file=$dir ."/For_PTMs_PMIDs_residues.txt";
	my $link_file= $dir . "/URL_to_protsIDs.txt.nointro";
	my $PTM_PMID_residues_file;
	my $PTM_interaction_file;
	my $legend_PMID_file;
	my $fasta_prot;
	open(DESC,$desc_file) || die $! ;
	my $id_entity=0;
	
	my $info_gene;
	my $info_age;
	my $info_family;
	my $info_path;
	my $info_pmid;
	my $info_age_id;
	my $info_tier_type;
	my $info_tier_pmid;
	my $info;
	my $info_net_id;
	my $info_path_id;
	my $info_family_id;
	my $info_net;
	my $invers_fasta_prot;
	print STDERR "\nReading and parsing $desc_file\n\n";
	while(<DESC>){
		chomp;
		my($Organism,$GeneName,$Synonym,$Gene_Age,$four_tier,$FamID,$Pathway,$SubNetwork,$PMID_interaction,$Displacements,$class_tree,$Agreement_species_tree,$single_gene_tree,$MultiGene_tree,$UniprotID,$UniprotName,$EnsemblID,$Descritpion)=split(/\t/);
		
		#exceptions
		$Descritpion=~s/\_/ /g;
		$Gene_Age=~s/\_/ /g;
		if($Gene_Age eq "Archaea"){
			$Gene_Age="Prokaryotes";
		}
		if($Gene_Age eq "Bacteria"){
			$Gene_Age="Prokaryotes";
		}
		if($Gene_Age eq "Plants"){
			$Gene_Age="Viridiplantae";
		}
		if($Gene_Age eq "Fungi"){
			$Gene_Age="Opisthokonta";
		}
		if($Gene_Age eq "other Eukaryotes"){
			$Gene_Age="early Eukaryotes";
		}
		if($Pathway eq "Dissolution of joint DNA molecules"){
			$Pathway="Holliday";
		}
		$Synonym=~s/\// /g;
		
		
		
		if($Organism eq "Homo_sapiens"){
			$id_entity++;
			if($EnsemblID =~ /\|/){
				my @data=split(/\|/,$EnsemblID);
				$EnsemblID=$data[0];
			}
			
			$info_gene->{$GeneName}->{"$Synonym,$UniprotID,$UniprotName,$Descritpion,$EnsemblID,$Organism,$Displacements,$class_tree,$Agreement_species_tree,$single_gene_tree,$MultiGene_tree"}=$id_entity;
			
			$info_age->{$Gene_Age}=$id_entity;
			$info_age_id->{$id_entity}=$Gene_Age;
			
			$info_family->{$FamID}=$id_entity;
			$info_family_id->{$id_entity}=$FamID;
			
			$info->{$id_entity}=$GeneName;
			
			$fasta_prot->{$UniprotID}=$id_entity;
			$invers_fasta_prot->{$id_entity}=$UniprotID;
			#Tier
			if($four_tier =~ "|"){ 
				my @split=split(/\|/,$four_tier);
				foreach my $info (@split){
					my($tier_type,$pmid_tier)=split("-",$info);
					$pmid_tier=~s/\(//g;
					$pmid_tier=~s/\)//g;
					if($pmid_tier =~ "\,"){
						my @pmids=split(/\,/,$pmid_tier);
						foreach my $pm (@pmids){
							$info_tier_pmid->{$id_entity}->{$tier_type}->{$pm}++;
							$info_tier_type->{$tier_type}++;
						}
					}
					else{
						$info_tier_type->{$tier_type}++;
						$info_tier_pmid->{$id_entity}->{$tier_type}->{$pmid_tier}++;
					}
				}
			}
			else{
				my($tier_type,$pmid_tier)=split("-",$four_tier);
				$pmid_tier=~s/\(//g;
				$pmid_tier=~s/\)//g;
				$info_tier_type->{$tier_type}++;
				$info_tier_pmid->{$id_entity}->{$tier_type}->{$pmid_tier}++;
			}
			#PMID
			if($PMID_interaction =~/\|/){
				my @pmis=split(/\|/,$PMID_interaction);
				foreach my $pms (@pmis){
					$info_pmid->{$pms}->{$id_entity}++;
				}
			}
			else{
				$info_pmid->{$PMID_interaction}->{$id_entity}++;
			}
			
			#Pathways
			if($Pathway =~ "|"){
				my @split=split(/\|/,$Pathway);
				foreach my $info (@split){
					$info_path->{$info}->{$id_entity}++;
					$info_path_id->{$id_entity}->{$info}++;
				}
			}else{
				$info_path->{$Pathway}->{$id_entity}++;
				$info_path_id->{$id_entity}->{$Pathway};
			}
			#Networks
			if($SubNetwork =~ "|"){
				my @split=split(/\|/,$SubNetwork);
				foreach my $info (@split){
					$info_net->{$info}->{$id_entity}++;
					$info_net_id->{$id_entity}->{$info}++;
				}
			}else{
				$info_net->{$SubNetwork}->{$id_entity}++;
				$info_net_id->{$id_entity}->{$SubNetwork}++;
			}
		}
	}
	close DESC;
	

	#For Pathways
	my $id_path=1;
	my $path_sql_file="/tmp/pathway.sql";
	my $path_rel_sql_file="/tmp/pathway_rel.sql";
	my $sql_path;
	
	open(PATH,">$path_sql_file") || die $!;
	open(PATHREL,">$path_rel_sql_file") || die $!;
	
	foreach my $path (keys %$info_path) {
		print PATH "$id_path\t".ucfirst($path)."\n";
		foreach my $id_ent (keys %{$info_path->{$path}}){
			print PATHREL $id_ent ."\t". "$id_path\n";
			$sql_path->{$path}=$id_path;
		}
		$id_path++;
	}
	close PATH;
	close PATHREL;
	importing($dbname,$path_sql_file);
	
	#For subnetwork
	my $id_net=1;
	my $net_sql_file="/tmp/network.sql";
	my $net_rel_sql_file="/tmp/network_rel.sql";
	my $sql_net;
	
	open(NET,">$net_sql_file") || die $!;
	open(NETREL,">$net_rel_sql_file") || die $!;
	
	foreach my $path (keys %$info_net) {
		print NET "$id_net\t".ucfirst($path)."\n";
		foreach my $id_ent (keys %{$info_net->{$path}}){
			print NETREL $id_ent ."\t". "$id_net\n";
			$sql_net->{$path}=$id_net;
		}
		$id_net++;
	}
	close NET;
	close NETREL;
	importing($dbname,$net_sql_file);
	
	#Relation Pathway-Network
	my $path_net;
	my $sql_path_net="/tmp/path_network.sql";
	open(PATHNET,">$sql_path_net") || die $!;
	my $saved;
	foreach my $id_ent (keys %$info_net_id){
		foreach my $path (keys %{$info_path_id->{$id_ent}}){
			foreach my $net (keys %{$info_net_id->{$id_ent}}){
				if(!exists $saved->{$net}->{$path}){
					print PATHNET $sql_path->{$path} ."\t" . $sql_net->{$net} ."\n";
					$saved->{$net}->{$path}++;
				}
			}
		}
	}
	close(PATHNET);
	importing($dbname,$sql_path_net);
	
	
	#For AGE
	my $id_age=1;
	my $age_sql_file="/tmp/age.sql";
	my $sql_age;
	open(AGE,">$age_sql_file") || die $!;
	foreach my $age (keys %$info_age) {
		print AGE "$id_age\t".ucfirst($age)."\t" . $info_age->{$age} ."\n";
		$sql_age->{$age}=$id_age;
		$id_age++;
	}
	close AGE;
	importing($dbname,$age_sql_file);
	
	#For Family 
	my $id_family=0;
	my $family_sql_file="/tmp/family.sql";
	my $sql_family;
	open(FAMILY,">$family_sql_file") || die $!;
	foreach my $family (sort {$a <=>$b} keys %$info_family) {
		print FAMILY "$id_family\t".$family."\n";
		$sql_family->{$family}=$id_family;
		$id_family++;
	}
	close FAMILY;
	importing($dbname,$family_sql_file);
	

	#For tier
	my $id_rel_tier=1;
	my $tier_sql_file="/tmp/tier.sql";
	my $tier_rel_sql_file="/tmp/tier_rel.sql";
	my $sql_tier;
	open(TIER,">$tier_sql_file") || die $!;
	open(TIERREL,">$tier_rel_sql_file") || die $!;
	#
	foreach my $ids (keys %$info_tier_pmid){
		print TIERREL $ids ."\t" . $id_rel_tier."\n";
		# print STDERR $ids ."=" . $info->{$ids} ."=>" . $id_rel_tier."\n";
		foreach my $type (keys %{$info_tier_pmid->{$ids}}){
			foreach my $pmid (keys %{$info_tier_pmid->{$ids}->{$type}}){
				print TIER $id_rel_tier ."\t$type\t$pmid\n";
			}
		}
		$sql_tier->{$ids}=$id_rel_tier;
		$id_rel_tier++;
	}
	close TIER;
	close TIERREL;
	importing($dbname,$tier_sql_file);
	
	#fasta
	my $cont=0;
	my $fasta;
	my $fastaFile="Uniprot_Human_DDR.fasta";
	open(SAVED_FASTA,">".$fastaFile) || die $!;
	foreach my $uniprotID (keys %$fasta_prot){
		my $file="/tmp/dummy.fasta";
		my $url="http://www.uniprot.org/uniprot/$uniprotID.fasta";
		getstore($url, $file);
		open(FASTA,$file)|| die $!;
		my $seq;
		while(<FASTA>){
			chomp;
			print SAVED_FASTA $_."\n";
			if($_ !~ /^>/){
				$_=~ s/\n//g;
				$seq .= $_;
			}
		}
		$fasta->{$fasta_prot->{$uniprotID}}=$seq;
		close FASTA;
	}
	#Entity
	my $entity_sql_file="/tmp/entity.sql";
	open(ENTITY,">$entity_sql_file") || die $!;
	my $ent;
	my $ent_id;
	foreach my $entry (keys %$info_gene){
		foreach my $extra_info (keys %{$info_gene->{$entry}}){
			my ($syn,@data)=split(/,/,$extra_info);
			my $id=$info_gene->{$entry}->{$extra_info};
			print ENTITY "$id\t$entry\t$syn\t". join("\t",@data) ."\t" . $fasta->{$id} ."\t". $sql_age->{$info_age_id->{$id}} ."\t". $sql_family->{$info_family_id->{$id}} ."\n";
			$ent->{$entry}=$id;
			$ent_id->{$id}=$entry;
			my @split=split(" ",$syn);
			foreach my $syns (@split){
				$ent->{$syns}=$id;
			}
		}
	}
	close ENTITY;
	importing($dbname,$entity_sql_file);
	
	#for PMID
	my $id_rel_pmid=1;
	my $pmid_sql_file="/tmp/pmid.sql";
	my $pmid_rel_sql_file="/tmp/pmid_rel.sql";
	
	open(PMID,">$pmid_sql_file") || die $!;
	open(PMIDREL,">$pmid_rel_sql_file") || die $!;
	
	foreach my $pmid (sort {$a <=>$b} keys %$info_pmid) {
		if($pmid =~ /^\d/ and $pmid =~ /\d$/){
			print PMID "$id_rel_pmid\t$pmid\n";
			foreach my $ids (keys %{$info_pmid->{$pmid}}){
				print PMIDREL "$ids\t$id_rel_pmid\n";
			}
			$id_rel_pmid++;
		}
	}
	close PMIDREL;
	close PMID;
	

	importing($dbname,$pmid_sql_file);
	importing($dbname,$pmid_rel_sql_file);
	importing($dbname,$tier_rel_sql_file);
	importing($dbname,$path_rel_sql_file);
	importing($dbname,$net_rel_sql_file);
	
	#Orthologs
	my $emergences;
	my $org_info;
	print STDERR "\n\nReading and parsing $emergence_tree_file\n\n";
	open(EMER,$emergence_tree_file) || die $!;
	while(<EMER>){
		chomp;
		my($org_code,$org_desc,$age,$org_emergence)=split(/\t/);
		if($org_code ne "NA"){
			$emergences->{$org_emergence}++;
			$org_info->{$org_code}->{$org_desc}=$org_emergence;
		}
	}
	close EMER;
	my $org_db;
	my $ortho_sql_file="/tmp/orthologs.sql";
	open(ORTH,">$ortho_sql_file") || die $!;
	my $id_org=1;
	foreach my $org_code (keys %$org_info){
		foreach my $org_desc(keys %{$org_info->{$org_code}}){
			print ORTH $id_org ."\t" . $org_code ."\t". $org_desc ."\t" .$sql_age->{$org_info->{$org_code}->{$org_desc}}. "\n";
			$org_db->{$org_code}=$id_org;
		}
		$id_org++;
	}
	close ORTH;
	importing($dbname,$ortho_sql_file);
	
	#Emergences
	
	#First adding link to id_orths
	my $links;
	open(LINK,$link_file) || die $!;
	while(<LINK>){
		chomp;
		my ($org_code,undef,$link)=split(/\t/);
		if($org_code !~ /^#/){
			$links->{$org_code}=$link;
		}
	}
	close LINK;
	
	
	print STDERR "\n\nReading and parsing $emergence_file\n\n";
	open(EMERF,$emergence_file) || die $!;
	my $cont=0;
	my @split_headers;
	my $emergence_sql_file="/tmp/emergence.sql";
	open(EMER,">$emergence_sql_file") || die $!;
	while(<EMERF>){
		chomp;
		if($cont==0){
			#headers
			(undef,undef,@split_headers)=split(/\t/);
		}
		else{
			#data
			my ($human_prot,undef,@split)=split(/\t/);
			for (my $var = 0; $var <=$#split_headers; $var++) {
				if($split[$var] eq 0){
					$split[$var]="NA";
					#print STDERR "Para $human_prot en el organismo $split_headers[$var], tengo $split[$var]\n";
				}
				if($split[$var] ne "NA"){
					#print $human_prot ."\t" . $split_headers[$var] ."\t" . $split[$var] ."\n";
					#print EMER "INSERT INTO emergence VALUES (".$ent->{$human_prot} ."," . $org_db->{$split_headers[$var]} .",\"" . $split[$var] . "\")\n";
					#print STDERR "For $split_headers[$var] =>(" .  $links->{$split_headers[$var]}."". $split[$var] .")\n";
					print EMER $ent->{$human_prot} ."\t" . $org_db->{$split_headers[$var]} ."\t" .$split[$var] ."\t". $links->{$split_headers[$var]}."\n";
					if($ent->{$human_prot} eq ""){
						print STDERR "$human_prot is not found\n";
					}
				}
			}
		}
		$cont++;
	}
	close EMERF;
	importing($dbname,$emergence_sql_file);
	
	#PTMs
	print STDERR "\n\nReading and parsing $PTM_file\n\n";
	my $ptm;
	#This is for genes with no modifications: see *
	my $mods->{"Not modified"}++;
	open(PTM,"$PTM_file") || die $!;
	while(<PTM>){
		chomp;
		if($_ !~/^Target/){
			my($target,undef,$modifier,undef,$modification)=split(/\t/);
			$modification=ucfirst($modification);
			$target=uc($target);
			$modifier=uc($modifier);
			#print "-$target-\t-$modifier-\t-$modification-\n";
			$ptm->{$target}->{$modifier}=$modification;
			$mods->{$modification}++;
		}
	}
	close PTM;
	
	print STDERR "\n\nReading and parsing $PTM_residue_file\n\n";
	open(RES,$PTM_residue_file) || die $!;
	my $residues;
	while(<RES>){
		chomp;
		my @pmids;
		my ($target,undef,$residue,$modifier,$pmid)=split(/\t/);
		$target=uc($target);
		$target=~s/\s+$//g;
		$modifier=uc($modifier);
		if($pmid =~ /\//){
			@pmids=split(/\//,$pmid);
		}
		else{
			$pmids[0]=$pmid;
		}
		if($modifier =~ "AUTO"){
			$modifier=$target;
		}
		if($modifier =~ " AND "){
			my($modifier1,$modifier2)=split(/ AND /,$modifier);
			foreach my $pm (@pmids){
				$residues->{$target}->{$modifier1}->{$residue}->{$pm}++;
				$residues->{$target}->{$modifier2}->{$residue}->{$pm}++;
			}
		}
		elsif($modifier =~ " OR "){
			my($modifier1,$modifier2)=split(/ OR /,$modifier);
			foreach my $pm (@pmids){
				$residues->{$target}->{$modifier1}->{$residue}->{$pm}++;
				$residues->{$target}->{$modifier2}->{$residue}->{$pm}++;
			}
		}
		elsif($modifier =~ /\+/){
			my($modifier1,$modifier2)=split(/\+/,$modifier);
			foreach my $pm (@pmids){
				$residues->{$target}->{$modifier1}->{$residue}->{$pm}++;
				$residues->{$target}->{$modifier2}->{$residue}->{$pm}++;
			}
		}
		else{
			foreach my $pm (@pmids){
				#print STDERR "$target\t$modifier\t$residue\t$pm\n";
				$residues->{$target}->{$modifier}->{$residue}->{$pm}++;
			}
		}
	}
	close RES;
	
	#Creating modifications
	my $id_modification=1;
	my $mod_file="/tmp/modification.sql";
	my $mod_id;
	open(MOD,">$mod_file") || die $!;
	foreach my $mod (keys %$mods){
		print MOD $id_modification ."\t" . $mod ."\n";
		$mod_id->{$mod}=$id_modification;
		$id_modification++;
	}
	close MOD;
	importing($dbname,$mod_file);
	
	my $id_ptm=1;
	my $modificadores;
#	my $residue_file="/tmp/residues.sql";
	my $PTMS_sql_file="/tmp/PTMs.sql";
	my $pdb_sql_file="/tmp/pdb.sql";
	
	open(PTMs,">$PTMS_sql_file") || die $!;
#	open(RESIDUE,">$residue_file") || die $!;
	open(PDB,">$pdb_sql_file") || die $!;
	foreach my $target (keys %$residues){
		foreach my $modifier (keys %{$residues->{$target}}){
			if(exists $ent->{$target} and exists $ent->{$modifier}){
				foreach my $residue (keys %{$residues->{$target}->{$modifier}}){
					#print STDERR "Gathering mapping in PDB for" . $invers_fasta_prot->{$ent->{$target}} ." $residue\n";
					my $info=getPDB($invers_fasta_prot->{$ent->{$target}},$residue);
					if(scalar(keys %$info)>0){
						foreach my $contador (keys %$info){
							if($info->{$contador}->{$residue}->{PDB}){
								#print "\n\nRecibo : Para $invers_fasta_prot->{$ent->{$target}} en $residue\n";
								system("wget http://www.rcsb.org/pdb/files/$info->{$contador}->{$residue}->{PDB}.pdb -nc -O ../Web/data/pdb/$info->{$contador}->{$residue}->{PDB}.pdb");
								#print $info->{$contador}->{$residue}->{AC} . " tiene mapeado el residuo $residue como " . $info->{$contador}->{$residue}->{RESID} ." en el PDB: " . $info->{$contador}->{$residue}->{PDB} .", cadena ($info->{$contador}->{$residue}->{CHAIN}) y " . $info->{$contador}->{$residue}->{START} .":". $info->{$contador}->{$residue}->{STOP} ."\n";
								print PDB $id_ptm ."\t". $info->{$contador}->{$residue}->{RESID} ."\t" . $info->{$contador}->{$residue}->{PDB} ."\t". $info->{$contador}->{$residue}->{CHAIN} ."\t" . $info->{$contador}->{$residue}->{START} ."\t" . $info->{$contador}->{$residue}->{STOP} ."\n";
							}
						}
					}
					foreach my $pmid (keys %{$residues->{$target}->{$modifier}->{$residue}}){
						$modificadores->{$ent->{$target}}="$residue\t$pmid";
						$modificadores->{$ent->{$modifier}}="$residue\t$pmid";
						if(!exists $saved->{$id_ptm}->{$residue.$pmid}){
							if($mod_id->{$ptm->{$target}->{$modifier}}){
								print PTMs $id_ptm ."\t" . $ent->{$target} ."\t" . $ent->{$modifier} . "\t". $mod_id->{$ptm->{$target}->{$modifier}} ."\t" . $residue ."\t" . $pmid ."\n";
								#print RESIDUE $id_ptm ."\t$residue\t$pmid\n";
								$saved->{$id_ptm}->{$residue.$pmid}=1;
								$id_ptm++;
							}
						}
					}
				}
			}
		}
	}
	foreach my $entity (keys %$ent_id){
		if(!exists $modificadores->{$entity}){
			# * Ni es target ni modifier
			my $modification="Not modified";
			print PTMs "$id_ptm\t" . $entity . "\t". $entity ."\t" . $mod_id->{$modification} ."\t" . $modificadores->{$entity} ."\n";
			$id_ptm++;
		}
	}
	close PTMs;
#	close RESIDUE;
	close PDB;
	importing($dbname,$PTMS_sql_file);
	#importing($dbname,$residue_file);
	importing($dbname,$pdb_sql_file);
	
	#Sorting
	system("mysql $dbname < ../SQL/sort_organism.sql");
}
elsif($help){
	help();
}
else{
	help();
}

sub importing{
	use File::Basename;
	my $dbname=shift;
	my $path_file=shift;
	my $file=fileparse($path_file);
	my $cmd="cd /tmp/ ; mysqlimport -d $dbname -L $file";
	#print $cmd ."\n";
	system($cmd) == 0
        or die "system $cmd failed: $?";
}

sub getPDB($$){
	my $uniprot=shift;
	my $residue=shift;
	my $residue_bck=$residue;
	
	#print "\n\nPara $uniprot en $residue encuentro :\n";
	if($residue eq "N\/A"){
		return();
	}
	elsif($residue =~ /^[a-zA-Z]/){
		$residue=~s/^[a-zA-Z]//g;
	}
	
	my $ext="http://www.bioinf.org.uk/cgi-bin/pdbsws/query.pl?plain=1&qtype=ac&id=$uniprot";

	my $data=get($ext);
	$data =~s/\n/:/g;
	$data =~s/\s+//g;
	my @split=split(":",$data);
	my $hash;
	my $cont=0;
	my $mapping_info;
	#print "\n\n";
	my $sel_pdb;
	for (my $var = 0; $var <=$#split; $var++) {
		if($split[$var] eq "\/\/"){
			$cont++;
			$var--;
		}
		if($split[$var] eq "PDB"){
			$sel_pdb=$split[$var+1];
		}
		if($split[$var] eq "START"){
			$mapping_info->{$sel_pdb}->{$residue_bck}->{START}=$split[$var+1];
		}
		if($split[$var] eq "STOP"){
			$mapping_info->{$sel_pdb}->{$residue_bck}->{STOP}=$split[$var+1];
		}
		$var++;
	}
	
	my $server="http://www.bioinf.org.uk";
	my $ext="http://www.bioinf.org.uk/cgi-bin/pdbsws/query.pl?plain=1&qtype=ac&id=$uniprot&res=$residue";

	my $data=get($ext);
	$data =~s/\n/:/g;
	$data =~s/\s+//g;
	my @split=split(":",$data);

	for (my $var = 0; $var <=$#split; $var++) {
		if($split[$var] eq "\/\/"){
			$cont++;
			$var--;
		}
		$hash->{$cont}->{$residue_bck}->{$split[$var]}=$split[$var+1];
		if($split[$var] eq "PDB"){
			$hash->{$cont}->{$residue_bck}->{START}=$mapping_info->{$split[$var+1]}->{$residue_bck}->{START};
			$hash->{$cont}->{$residue_bck}->{STOP}=$mapping_info->{$split[$var+1]}->{$residue_bck}->{STOP};
		}
		#print "$split[$var] => $split[$var+1]\n";
		$var++;
	}
	
	return($hash);	
}
sub help{
        my $usage = qq{
          $0 

            Getting help:
                [--help]

            Needed parameters:
                [dir] Folder with Ana's DDR info                 

            Examples:
                 perl $0  -dir=../data_for_Edu/Tables_source_data/ -dbname=DDR_120314
                       
};

print STDERR $usage;
exit();
        
}

__END__

head1 NAME

Parse_and_Insert - Perl Module to ..

=head1 SYNOPSIS

=head1 DESCRIPTION

=head1 Parse_and_Insert

=over 2

=item a

bla bla1

=item b

bla bla2

=back

=head1 EXAMPLE
