From: elserj Date: Tue, 7 Sep 2010 22:22:07 +0000 (+0000) Subject: Added script to find interactions given a list of genes X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=968a02f1c8d4430366d9c7c666d8c0d207202ff6;p=old-jaiswallab-svn%2F.git Added script to find interactions given a list of genes svn path=/; revision=30 --- diff --git a/interactome_scripts/find_matching_interactions.pl b/interactome_scripts/find_matching_interactions.pl new file mode 100755 index 0000000..1fc77cf --- /dev/null +++ b/interactome_scripts/find_matching_interactions.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +# program to take a list of genes, and find all interactions in an interaction file (sif format) +# where both interaction genes are in the list + +if($#ARGV != 2) { + print "usage: find_matching_interactions.pl input_gene_list interaction_file output_file\n"; + exit; +} + +my $in_file = $ARGV[0]; +my $inter_file = $ARGV[1]; +my $out_file = $ARGV[2]; + +# read in the genes to look for +open (in_file, "$in_file"); + +my %in_hash; +while() { + my $line = $_; + chomp $line; + + $in_hash{$line} = $line; +} + +# read in the interaction file and do the lookups +open (inter_file, "$inter_file"); +open (out_file, ">$out_file"); + +while() { + my $line = $_; + chomp $line; + my ($inter_1, $type, $inter_2) = split("\t", $line); + if(defined($in_hash{$inter_1}) && defined($in_hash{$inter_2}) ) { + print out_file "$line\n"; + } +}