Skip to content

Commit

Permalink
I broke a long one-liner in matching.html into it's own perl program …
Browse files Browse the repository at this point in the history
…(dist.pl)

and changed it in minor ways to get it working.
  • Loading branch information
jhannah committed Mar 11, 2010
1 parent 5b5f3d0 commit c9ffaf3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions dist.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# This program is listed as a one-liner in matching.html. One-liners are hard to debug,
# though, so I'm pulling it out into a normal program. --jhannah 20100311

$dist = 1000;
use strict;

my (@data, @olddata, $dist);
while (<>) {
@data = split;
if ($data[3] eq "-") {
Expand All @@ -13,13 +15,13 @@
}
print "@data[0..5] 1000 $data[6]\n"
} else {
$dist = $data[2] - $olddata[2];
print "@olddata[0..5] $dist $data[6]\n@data[0..5] $dist $data[6]\n";
}
} else {
$dist = @olddata ? $data[2] - $olddata[2] : 1000;
}
@olddata = @data;
}
print "@olddata[0..5] 1000 $data[6]\n";ii

print "@olddata[0..5] 1000 $data[6]\n";


6 changes: 3 additions & 3 deletions matching.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ <h2>
<p>
Because we'll want to exclude analysis of sites too close to each other (and so they would interfere with each other) we want to add a column to the data indicating distance to the neighboring site. We did this with command line perl code like the following (note that this code assumes that the upstream sites precede the downstream sites in the input file):
</p>
<p>
cat CCGG_tags_18 | perl -ne 'BEGIN {$dist = 1000;} @data = split; if ($data[3] eq "-") {if ($data[1] ne $olddata[1]) { if (@olddata) { print "@olddata[0..5] 1000 $data[6]\n";}; print "@data[0..5] 1000 $data[6]\n";} else {$dist = $data[2] - $olddata[2]; print "@olddata[0..5] $dist $data[6]\n@data[0..5] $dist $data[6]\n";} }; @olddata = @data; END {print "@olddata[0..5] 1000 $data[6]\n";}' &gt CCGG_tags_18_withdist
</p>
<pre>
perl dist.pl CCGG_tags_18 &gt CCGG_tags_18_withdist
</pre>
<p>
This ends up looking like this:
</p>
Expand Down

0 comments on commit c9ffaf3

Please sign in to comment.