Get the App
SLTechnology News&Howtos  ›  Development  › 

How does perl extract the gene structure information of the corresponding transcript ID from the gff file?

Shulou Source: shulou.com Published: 2022-06-01 04:49:53 09月22日 Update

This article mainly explains "how to extract the gene structure information of the corresponding transcript ID from the gff file by perl". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to extract the gene structure information of the corresponding transcript ID from the gff file by perl".

Script source code:

Use Getopt::Long;my% opts;use Data::Dumper;GetOptions (\% opts, "in1=s", "in2=s", "out=s", "h"); if (! defined ($opts {in1}) | |! defined ($opts {in2}) | |! defined ($opts {out}) | defined ($opts {h})) {& USAGE } open (IN1, "$opts {in1}") | | die "open $opts {in1} failed\ n"; open (IN2, "$opts {in2}") | | die "open $opts {in2} failed\ n"; open (OUT, "> $opts {out}") | die "open $opts {out} failed\ n"; my% gffs;while () {chomp; next if / ^ # /; my @ b = split/\ tBank, $_ _ $gffs {$b [0]} = 1;} # print Dumper (\% gffs); while () {chomp; next if (/ ^ # /); my @ a = split /\ t exon/i, $_; next if $a [2] = ~ / exon/i If ($a [2] = ~ / ^ mRNA$/i or $a [2] = ~ / ^ transcript$/i) {($id1) = ($a [8] = ~ elsif ID = ([^;] *) /);} elsif ($a [2] = ~ / ^ CDS$/i or $a [2] = ~ / utr/i) {($id1) = ($a [8] = ~ mdeband Parent = ([^;] *) /) } else {next;} if (exists $gffs {$id1}) {print OUT "$_\ n";}} close OUT;close IN1;close IN2;sub USAGE {print "usage: perl $0-in1 mRNA_id.txt-in2 genome.gff3-out gene_location.txt"; exit } at this point, I believe you have a deeper understanding of "how perl extracts the gene structure information of the corresponding transcript ID from the gff file". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Information genes files structure content learning practicality deeper interest practicality practicality simplicity of operation methods more friends source code websites scripts channels queries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Huawei Apple NVidia