HI,
I have this file format
chr start end strand
x 12 24 1
x 24 48 1
1 100 124 -1
1 124 148 -1
Basically I would like to create a new file by grouping the start of the
first line (12) with the end of the second line (48) and so on
the output should look like this:
x 12 48 1
1 100 148 -1
I have this script to split and iterate over each line, but I don't
know how to group 2 lines together, and take the start of the firt line
and the end on the second line? could you please advise? thanks
unless (open(FH, $file)){
print "Cannot open file \"$file\"\n\n";
}
my @list = <FH>;
close FH;
open(OUTFILE, ">grouped.txt");
foreach my $line(@list){
chomp $line;
my @coordinates = split(/' '/, $region);
my $chromosome = $coordinates[0];
my $start = $coordinates[1];
my $end = $coordinates[2];
my $strand = $coordinates[3];
...???
--
The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/