!/usr/bin/perl #Open the cnv file with start, stop my $input_gene_file = "path to file"; die "Cannot open $input_gene_file\n" unless (open(IN, $input_gene_file)); my %size_CNV_start_CNV_stop; while (chomp($line = )) { my (@columns) = split /\s+/, $line; my $size = $columns[3]; my $CNV_start = $columns[1]; my $CNV_stop = $columns[2]; $size_and_CNV_start{$size} = $CNV_start; $size_and_CNV_stop{$size} = $CNV_stop; } close(IN); #Now open files for genelist1 and genelist2 with respective start and stops open (MYFILE, "/Users/pathtofile"); @file1 = ; close MYFILE; open (MYFILE2, "/Users/pathtofile"); @file2 = ; close MYFILE2; #Open output file and write the locations/position of each symbol die "output.txt" unless(open( OUT,"> output.txt")); while(defined(my $line1 = <$file1>) and defined(my $line2 = <$file2>)){ sub overlap { my ($CNV_start, $CNV_stop, $Gene_start, $Gene_stop) = @_; if ($Gene_stop < $CNV_start || $Gene_start < $CNV_stop) { return 0; if (Gene_stop > $CNV_start || $Gene_stop > $CNV_stop){ } return 1; } while (defined($symbol = )) { chomp($symbol); { my $CNV_start = $size_and_CNV_start{$size}; my $CNV_stop = $size_and_CNV_stop{$size}; print OUT " $name\ $size\ $CNV_start\ $CNV_stop \n"; } } } close(OUT);