From 7eb3d9a9bd6ab77defd10933335c358d166934fe Mon Sep 17 00:00:00 2001 From: elserj Date: Thu, 10 Mar 2016 21:42:40 +0000 Subject: [PATCH] Input species order no longer matters. Added extra argument to make it detect which species to search for in sql statement svn path=/; revision=643 --- interactome_scripts/find_ortho_inpara.pl | 33 +++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/interactome_scripts/find_ortho_inpara.pl b/interactome_scripts/find_ortho_inpara.pl index 600cd27..748d7a5 100755 --- a/interactome_scripts/find_ortho_inpara.pl +++ b/interactome_scripts/find_ortho_inpara.pl @@ -12,28 +12,41 @@ use strict; use warnings; -if($#ARGV != 3) { - print "usage: find_ortho_inpara.pl species_1 species_2 input_gene_list output_file\n"; +if($#ARGV != 4) { + print "usage: find_ortho_inpara.pl species_1 species_2 input_species input_gene_list output_file\n"; exit; } use lib "$ENV{HOME}/scripts/jaiswallab/interactome_scripts"; + +my @temp_array = ($ARGV[0], $ARGV[1]); +my @species_array = sort @temp_array; +my $spec_array_size = @species_array; + + use DbiFloret; my $dbh = DbiFloret::dbconnect; -my @species_array = ($ARGV[0], $ARGV[1]); -#my @species_array = ("Arabidopsis_thaliana", "Zea_mays"); -#my @species_array = ("Ath", "Maize"); -my $spec_array_size = @species_array; - # similarity score to determine if we should keep the paralogs. # 0.0 would keep all paralogs, 1.0 would restrict to strict orthologs my $sim_score = 0.1; +# input species, needed to fix sth_get_ortho species_array index to the opposite +my $in_species = $ARGV[2]; +my $species_index; +if($in_species eq $species_array[0]) { + $species_index = 1; +}elsif($in_species eq $species_array[1]) { + $species_index = 0; +}else{ + print "input_species doesn't match!!!/n"; + die; +} + # read in list of genes from csv file given as argument -my $in_file = $ARGV[2]; +my $in_file = $ARGV[3]; open (in_file, "$in_file"); @@ -56,7 +69,7 @@ my %ortho_hash; for (my $i = 1; $i<$spec_array_size; $i++) { - my $out_file = $ARGV[3]; # . "_$species_array[3].txt"; + my $out_file = $ARGV[4]; # . "_$species_array[3].txt"; open(out_file, ">$out_file"); my $table = $species_array[0] . "_" . $species_array[$i]; @@ -68,7 +81,7 @@ for (my $i = 1; $i<$spec_array_size; $i++) { my $sth_get_id = $dbh->prepare("select id from $safe_table where gene like ?"); # set up db query statement to get the orthologs using the cluster id - my $sth_get_ortho = $dbh->prepare("select gene, score from $safe_table where id = ? and species = '$species_array[1]' and score >= '$sim_score'"); + my $sth_get_ortho = $dbh->prepare("select gene, score from $safe_table where id = ? and species = '$species_array[$species_index]' and score >= '$sim_score'"); foreach my $gene (@in_gene_array) { -- 2.34.1