Skip to content

Instantly share code, notes, and snippets.

@toniher
Created February 14, 2019 11:23
Show Gist options
  • Save toniher/0692c6f1476b2aa8448c838cd557928e to your computer and use it in GitHub Desktop.
Save toniher/0692c6f1476b2aa8448c838cd557928e to your computer and use it in GitHub Desktop.
Handy parse of GFF files
#!/usr/bin/env perl
# List of IDs - one per line
my $list = shift;
# File with potential IDs, it can be GFF but also othersH
my $gff = shift;
my @ids;
open( LIST, $list ) || die "Cannot open $list";
while( <LIST> ) {
my ($id) = $_=~/^(\S+)/;
push( @ids, $id );
}
close( LIST );
foreach my $id ( @ids ) {
my $geneid = $id;
$geneid=~s/P\d+\s*$//g;
open (GFF, $gff );
while( <GFF> ) {
if ( $_=~$geneid ) {
print;
}
}
close( GFF );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment