From: athreyab Date: Tue, 24 Jan 2012 19:51:05 +0000 (+0000) Subject: added a few comments and support to check if the interaction already in tsv script X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=92d93d64670dbbc422416954c9b61b2c41d465a0;p=old-jaiswallab-svn%2F.git added a few comments and support to check if the interaction already in tsv script svn path=/; revision=274 --- diff --git a/Personnel/athreyab/interactions/interactionPathsFromSif.pl b/Personnel/athreyab/interactions/interactionPathsFromSif.pl index c4cb9ce..3a32d0a 100644 --- a/Personnel/athreyab/interactions/interactionPathsFromSif.pl +++ b/Personnel/athreyab/interactions/interactionPathsFromSif.pl @@ -30,8 +30,11 @@ sub showUsage #interaction type in sif files is in abbreviated format - 'pp','up',''down' etc. This function retrieves the #full format. +#accepts abbreviated interaction type as argument +#returns interaction type id from db sub getInteractionTypeForSifFormat { + # %interaction_types = map containing abbreviated and full forms of interaction_type as a key-value pair ($abbreviated_interaction_type) = @_; while ( ($key, $value) = each %interaction_types ) { @@ -42,6 +45,7 @@ sub getInteractionTypeForSifFormat } $interaction_type ne "" || die "$abbreviated_interaction_type may not be present in the db"; + #get interaction type id from the db return getInteractionTypeId($interaction_type); } @@ -57,8 +61,10 @@ sub importParalogData chomp $entry; $entry =~ s/\r//g; $entry =~ s/\n//g; + # split the columns into 3 separate variables my ($obj_l, $obj_r, $score) = split("\t", $entry); + # skip next if(!defined($score)); next if($score =~ /D/); @@ -81,7 +87,7 @@ sub importParalogData $obj_id_r = getObjectIdFromAccession($obj_r); } - #check if the homology between the accessions is already recorded. If it is already, check the scores and + #check if the homology between the accessions is already recorded. If it is recorded already, check the scores and #store the highest score. If the relation doesn't exist, insert into the homology table. ($homology_id,$origScore) = getHomologyIdAndScore($obj_id_l,$obj_id_r,$score); if(isEmpty($homology_id) || $origScore < $score){ @@ -101,12 +107,15 @@ sub importOrthologData open(paralog_file, "$fileName") || die "Error: file '$fileName' can not be opened\n"; while(){ my $entry = $_; + # strip off newline characters chomp $entry; $entry =~ s/\r//g; $entry =~ s/\n//g; + # split the columns into 3 separate variables my ($obj_l, $obj_r, $score) = split("\t", $entry); + # skip next if(!defined($score)); next if($score =~ /D/); @@ -149,13 +158,15 @@ sub importSifData print "reading seed interaction information from $fileName\n"; open(interactions_file, "$fileName") || die "Error: file '$fileName' can not be opened\n"; - print "Species id: ".$speciesIdForSif."\n"; + while(){ my $entry = $_; + # strip off newline characters chomp $entry; $entry =~ s/\r//g; $entry =~ s/\n//g; + # split the columns into separate variables my ($accession_left,$interaction_type,$accession_right) = split("\t", $entry); @@ -175,7 +186,11 @@ sub importSifData next if(isEmpty($accession_left_id) || isEmpty($accession_right_id) || isEmpty($interaction_type_id)); - #check if the interaction is already recorded. Write to database only if it doesn't exist already. + #check if the interaction is already recorded. Write to database only if it doesn't exist already.e + #an interaction is considered new under two conditions: + #a. interaction has not been recorded previously + #b. interaction is already recorded, but by a different curator - this is not something that we need right now + #but in the future, we may allow people other than the devs to upload the data themselves. $interactionId = getInteractionId($accession_left_id,$interaction_type_id,$accession_right_id,$curator_id); print "interaction id is: $interactionId\n"; if(isEmpty($interactionId)){ @@ -192,7 +207,7 @@ if($optionId ne "0" && $#ARGV != 1){ showUsage(); } - +#some initializations $fileName = $ARGV[1]; $speciesIdForSif=""; $speciesIdForParalog=""; diff --git a/Personnel/athreyab/interactions/interactionPathsFromTsv.pl b/Personnel/athreyab/interactions/interactionPathsFromTsv.pl index 291b4cf..99ea7a5 100644 --- a/Personnel/athreyab/interactions/interactionPathsFromTsv.pl +++ b/Personnel/athreyab/interactions/interactionPathsFromTsv.pl @@ -21,8 +21,7 @@ sub showUsage(){ print "Usage: \n\tperl interactionPathsFromTsv