Last active
February 20, 2019 11:29
-
-
Save epaule/b1fdf825b85884f3df153f9d63dd6069 to your computer and use it in GitHub Desktop.
fiddles with the GFF3 mRNA spans based on CDSes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
my $inf = shift; | |
open IN, $inf; | |
my %cds; | |
# slurpy block | |
while (<IN>){ | |
chomp; | |
my @F = split; | |
if (/Parent=([^;]+)/){ | |
my $id = "$1"; | |
$cds{$id}->{start}||=$F[3]; | |
$cds{$id}->{stop}||=$F[4]; | |
$cds{$id}->{start}=$F[3] if $F[3] < $cds{$id}->{start}; | |
$cds{$id}->{stop}=$F[4] if $F[4] > $cds{$id}->{stop}; | |
} | |
} | |
close IN; | |
# fixie block | |
# while (my ($k,$v)= eadch %cds){ | |
# print "funky " | |
# } | |
open IN, $inf; | |
while (<IN>){ | |
if (/ID=([^;\n]+)/){ | |
my @F=split; | |
my ($newStart,$newStop) = ($cds{$1}->{start},$cds{$1}->{stop}); | |
my ($oldStart,$oldStop) = ($F[3],$F[4]); | |
s/$oldStart/$newStart/; | |
s/$oldStop/$newStop/; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment