#!/usr/bin/perl ############################################################################# #extract_genes_from_TIGR_XML.pl #Extracting coordinates from TIGR's XML annotation files. #Copyright (c) 2005 Diego Mauricio Riaño Pachón #http://www.geocities.com/dmrp.geo # #This script requires XML::Simple and the TIGRXMLLIB available #from TIGR's web site ftp://ftp.tigr.org/pub/data/a_thaliana/ath1/XML_TOOLS/ # #This program is free software; you can redistribute it and/or #modify it under the terms of the GNU General Public License #as published by the Free Software Foundation; either version 2 #of the License, or (at your option) any later version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ############################################################################# use lib ("TIGRXMLLIB"); use TIGR_XML_parser; use Gene_obj; use strict; use warnings; use Getopt::Long; #use diagnostics; my $version=1.0; my $license=""; my $help=""; my @files=(); GetOptions( 'file|f=s' => \@files, 'license|l' => \$license, 'help|h|?' => \$help ); if (@files){ foreach my $file(@files){ my $output=$file; $output=~s/\.xml$/\.tbl/; open OUT, ">$output"; my $TIGRparser=new TIGR_XML_parser(); my $pwd=`pwd`; chomp $pwd; unless ($file=~/\//){ $file="$pwd/$file"; } print STDERR $file."\n"; $TIGRparser->capture_genes_from_assembly_xml("$file"); my @genes=$TIGRparser->get_genes(); print OUT "TYPE\tLOCUS\tMODEL\tMODEL_END5\tMODEL_END3\tGENE_END5\tGENE_END3\n"; foreach my $gene(@genes){ $gene->refine_gene_object(); #From Gene_obj.pm: this are the different gene types: protein-coding|rRNA|snoRNA|snRNA|tRNA #I will keep separated protein-coding genes from RNA genes #additionaly pseudogenes are annotated as proteins coding genes, then an additional step is needed to take them apart. #I added a tag at the beginning of each row to distinguish between protein-coding, pseudogene and RNAgene if($gene->{gene_type}=~/^protein-coding$/){ if ($gene->{is_pseudogene}==0){ my $model=$gene->{model_pub_locus}; my ($modelend5,$modelend3)=$gene->get_model_span(); my ($genend5,$genend3)=$gene->get_gene_span(); print OUT "protein-coding\t".$gene->{pub_locus}."\t$model\t$modelend5\t$modelend3\t$genend5\t$genend3\n"; my @isoforms=$gene->get_additional_isoforms(); if (@isoforms){ foreach my $isoform(@isoforms){ my $model=$isoform->{model_pub_locus}; my ($modelend5,$modelend3)=$isoform->get_model_span(); my ($genend5,$genend3)=$gene->get_gene_span(); print OUT "protein-coding\t".$gene->{pub_locus}."\t$model\t$modelend5\t$modelend3\t$genend5\t$genend3\n"; } } } else{ my $model=$gene->{model_pub_locus}; my ($modelend5,$modelend3)=$gene->get_model_span(); my ($genend5,$genend3)=$gene->get_gene_span(); print OUT "pseudogene\t".$gene->{pub_locus}."\t$model\t$modelend5\t$modelend3\t$genend5\t$genend3\n"; my @isoforms=$gene->get_additional_isoforms(); if (@isoforms){ foreach my $isoform(@isoforms){ my $model=$isoform->{model_pub_locus}; my ($modelend5,$modelend3)=$isoform->get_model_span(); my ($genend5,$genend3)=$gene->get_gene_span(); print OUT "pseudogene\t".$gene->{pub_locus}."\t$model\t$modelend5\t$modelend3\t$genend5\t$genend3\n"; } } } } else{ my ($genend5,$genend3)=$gene->get_gene_span(); print OUT "RNAgene\t".$gene->{pub_locus}."\t\t$genend5\t$genend3\t$genend5\t$genend3\n"; } } } } elsif($license){ &license; } else{ &usage; } sub usage{ print STDERR "$0 version $version, Copyright (C) 2005 Diego Mauricio Riaño Pachón\n"; print STDERR "$0 comes with ABSOLUTELY NO WARRANTY; for details type `$0 -l'.\n"; print STDERR "This is free software, and you are welcome to redistribute it under certain conditions;\n"; print STDERR "type `$0 -l' for details.\n"; print STDERR <