Get the App
SLTechnology News&Howtos  ›  Development  › 

How to extract the location information of all transcripts in GFF by perl

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

This article mainly explains "how to extract the location information of all transcripts in GFF by perl". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to extract the location information of all transcripts in GFF by perl.

Extract the location information of all gene transcripts in the genome annotation file GFF, as well as the ID of the corresponding genes:

The perl code is as follows:

#! / usr/bin/perl-wuse strict;use Cwd qw (abs_path getcwd); use Getopt::Long;use Data::Dumper;die "perl $0" unless (@ ARGV==2); my$gff=$ARGV [0]; my%gene= (); my%gene_region= (); my%mRNA2Gene= (); open IN, "$gff" or die "$!"; open OUT, "> $ARGV [1]" or die "$!"; print OUT "# mRNA_ID\ tgene_ID\ tchr\ tstart\ tend\ tstrand\ n"; while () {chomp Next if (/ ^ # /); my@tmp=split (/\ t /); if ($tmp [2] = ~ / ^ gene/) {my ($id) = ($tmp [8] = ~ / ID= ([^;] +) /); $gene {$id} = 1 leading genetic region {$id} = [$tmp [0], $tmp [3], $tmp [4], $tmp [6]; # print "gene:$id\ n"; # my$gene_chr- > {$id = $tmp [0] } if ($tmp [2] = ~ / mRNA | transcript/i) {my ($id) = ($tmp [8] = ~ / ID= ([^;] +) /); my ($pid) = ($tmp [8] = ~ / Parent= ([^;] +) /); if (exists $gene {$pid}) {print OUT "$id\ t$pid\ t$tmp [0]\ t$tmp [3]\ t$tmp [4]\ t$tmp [6]\ n";} # print "mRNA:$id\ n";}} close (IN); close (OUT) At this point, I believe you have a deeper understanding of "how perl extracts the location information of all transcripts in GFF". 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: Location information genes content learning practical deeper code interest genome practicality practical easy to operate files methods more friends comments websites channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple Huawei Docker Shulou Information