#!perl -w use strict; use warnings; use Getopt::Long; use ScriptManager; my ($out,$in); GetOptions( "help|h" =>\&USAGE, "o:s"=>\$out, "i:s"=>\$in, ); &USAGE unless ($in && $out); my @lncRNA_type=qw (lncRNA 3prime_overlapping_ncRNA antisense bidirectional_promoter_lncRNA lincRNA macro_lncRNA non_coding processed_transcript sense_intronic sense_overlapping TEC lnc_RNA); my %type; map {$type{$_}=1} @lncRNA_type; open IN,$in or die $!; open OUT,">$out"; while () { next if(/^\#/); print OUT $_ if(/gene_biotype \"([^\"]+)\"/ && $type{$1}); print OUT $_ if(/transcript_biotype \"([^\"]+)\"/ && $type{$1}); } close IN; close OUT; # remove $out if $out is empty #unlink $out if -f $out && -z $out; sub USAGE{ my $usage=<<"USAGE"; Usage:perl $0 -i reference.gtf -o lncRNA.gtf Options: -i reference.gtf containing "gene_biotype" attribute, forced -o output file, forced -h|help help USAGE print$usage; exit; }