script/uniprotdat2fasta.pl untested

filter: Statementstmt 0.0% 0 / 70 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 22 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 0.0% 0 / 8 Podpod n/a totaltotal 0.0% 0 / 142 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 use strict;
3 use Carp;
4 use Pod::Usage;
5  
6 =head1 NAME
7  
8 uniprotdat2fasta.pl - converts uniprot native text format (.dat or .seq) into fasta file, reporting varsplic, signal, peptide, PTM, conflicts....
9  
10 =head1 DESCRIPTION
11  
12 Reads a uniprot .dat (sprot, trembl...) and converts it into a fasta file, expanding VAR_SPLIC, CHAIN, PEPT annotations.
13  
14 FT annotation, such as MOD_RES, VARIANT... are kept in the fasta header coherently with the sequence modification (recomputed location).
15  
16 =head1 SYNOPSIS
17  
18 uniprotdata2fasta.pl --in=uniprot_sprot.dat --out=uniprot_sprot.fasta
19  
20 =head1 ARGUMENTS
21  
22  
23 =head3 --in=file
24  
25 A .dat file [default is stdin]
26  
27 =head3 -out=file
28  
29 A .fasta file [default is stdout]
30  
31  
32 =head1 OPTIONS
33  
34 =head3 --noderived
35  
36 Does not produce the derived sequences, i.e. the chains, peptides and isoforms (VAR_SEQ, CHAIN...). Equivalent to call with -skipchains -skippeptides -skipisoforms.
37  
38 =head3 --skipchains
39  
40 Does not produce the chains.
41  
42 =head3 --skippeptides
43  
44 Does not produce the peptides.
45  
46 =head3 --skipisoforms
47  
48 Does not produce the isoforms.
49  
50 =head3 --skiporigsequence
51  
52 By default the original sequence is always added to the fasta file and then new sequences (chains, etc.) are added provided they are different. To avoid having the original sequence and to have annotated features only, use this flag.
53  
54 =head3 --shortname
55  
56 The additional sequences have ACs that are obtained by appending a text to the original AC. For Mascot it might be necessary to configure the system to accept longer ACs than it does by default. To avoid this you can use this flag and peptides will be named AC_Pi, chains AC_Ci, and isoforms AC_Ii, where i is an integer starting at 0 for each type of variant.
57  
58 =head3 --help
59  
60 =head3 --man
61  
62 =head3 --verbose
63  
64 Setting an environment vartiable DO_NOT_DELETE_TEMP=1 will keep the temporay file after the script exit
65  
66 =head1 EXAMPLE
67  
68  
69 =head1 COPYRIGHT
70  
71 Copyright (C) 2004-2006 Geneva Bioinformatics www.genebio.com
72  
73 This library is free software; you can redistribute it and/or
74 modify it under the terms of the GNU Lesser General Public
75 License as published by the Free Software Foundation; either
76 version 2.1 of the License, or (at your option) any later version.
77  
78 This library is distributed in the hope that it will be useful,
79 but WITHOUT ANY WARRANTY; without even the implied warranty of
80 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
81 Lesser General Public License for more details.
82  
83 You should have received a copy of the GNU Lesser General Public
84 License along with this library; if not, write to the Free Software
85 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
86  
87 =head1 AUTHORS
88  
89 Alexandre Masselot, www.genebio.com
90  
91 =cut
92  
93  
94  
95 use InSilicoSpectro::Databanks::DBEntryUniprot;
96 use SelectSaver;
97 use File::Basename;
98  
99 use Getopt::Long;
100 my($datFile, $fastaFile, $noDerivedForm, $help, $man, $verbose, $skipChains, $skipIsoforms, $skipPeptides, $skipOrigSeq, $shortName);
101 $datFile='-';
102 $fastaFile='-';
103  
104 if (!GetOptions(
105 "in=s"=>\$datFile,
106 "out=s" => \$fastaFile,
107  
108 "noderived"=>\$noDerivedForm,
109 'skippeptides' => \$skipPeptides,
110 'skipchains' => \$skipChains,
111 'skipisoforms' => \$skipIsoforms,
112 'skiporigseq' => \$skipOrigSeq,
113 'shortname' => \$shortName,
114  
115 "help" => \$help,
116 "man" => \$man,
117 "verbose" => \$verbose,
118 )
119 || $help || $man){
120  
121  
122 pod2usage(-verbose=>2, -exitval=>2) if(defined $man);
123 pod2usage(-verbose=>1, -exitval=>2);
124 }
125  
126  
127 my ($pg, $size, $nextpgupdate, $readsize);
128 $readsize=0;
129 $nextpgupdate=0;
130  
131 eval{
132 if (($datFile ne '-')&& -t STDIN && -t STDOUT){
133 require Term::ProgressBar;
134 $size=(stat $datFile)[7];
135 $pg=Term::ProgressBar->new ({name=> "parsing ".basename($datFile), count=>$size});
136 }
137 };
138 if ($@){
139 warn "could not use Term::ProgressBar (consider installing the module for more interactive use";
140 }
141  
142  
143 open (FDIN, "<$datFile") or die "could not open for reading [$datFile]:$!";
144  
145 my $saver;
146 if ($fastaFile ne '-'){
147 open (FDOUT, ">$fastaFile") or die "could not open for writing [$fastaFile]:$!";
148 $saver=new SelectSaver(\*FDOUT);
149 }
150  
151  
152 $/="\n//\n";
153 while (<FDIN>){
154 $readsize+=length $_;
155 $nextpgupdate=$pg->update($readsize) if $pg && $readsize>$nextpgupdate;
156 next unless /\S/;
157 my $dbu=InSilicoSpectro::Databanks::DBEntryUniprot->new;
158 $dbu->readDat($_);
159 # if ($dbu->AC){
160 unless($noDerivedForm){
161 my %params;
162 $params{skipChains} = 1 if (defined($skipChains));
163 $params{skipPeptides} = 1 if (defined($skipPeptides));
164 $params{skipIsoforms} = 1 if (defined($skipIsoforms));
165 $params{shortName} = 1 if (defined($shortName));
166 my @tmp=$dbu->generateDerivedForms(%params);
167 my $origSeq;
168 unless (defined($skipOrigSeq) && @tmp){
169 $dbu->printFasta;
170 $origSeq = $dbu->sequence;
171 }
172 foreach (@tmp){
173 if ($_->sequence ne $origSeq){
174 $_->printFasta;
175 }
176 }
177 }else{
178 $dbu->printFasta;
179 }
180 # }
181 }
182 $pg->update($size) if $pg;
183 exit(0);