perllearner007 has asked for the wisdom of the Perl Monks concerning the following question:
file1=cnv file start stop size(in bp) 5389769 98256008 3567 7452344 871875466 64547
file2=genelist1 name start stop BRCA1 41196312 41277500 TP53 7571720 7590863
note: I cannot merge the two gene lists as they are different sets and need to be kept separate. Am I doing this correctly? Any suggestions?file3=genelist3 name start stop OMG 29621668 29624380 NR3C1 142657496..142815077
I get a blank output file. There is no error or warning that I am getting so I am not sure what is going on and what I should be correcting? My output file should be if overlapping regions found!/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 = <IN>)) { 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 = <MYFILE>; close MYFILE; open (MYFILE2, "/Users/pathtofile"); @file2 = <MYFILE2>; 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 = <IN>)) { 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);
gene name size start stop xyz 5464 83654272 6735353 ... ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: overlapping regions
by brx (Pilgrim) on Apr 24, 2012 at 15:15 UTC | |
by perllearner007 (Acolyte) on Apr 24, 2012 at 16:00 UTC | |
|
Re: overlapping regions
by Cristoforo (Curate) on Apr 25, 2012 at 00:31 UTC | |
by perllearner007 (Acolyte) on Apr 25, 2012 at 13:58 UTC |