root/bin/fix_fasta

Revision 224, 0.9 kB (checked in by cholt, 5 months ago)

update mpi_iprscan

  • Property svn:executable set to *
Line 
1 #! /usr/bin/perl
2 use strict;
3 use FindBin;
4 use lib "$FindBin::Bin/../lib";
5 use lib "$FindBin::Bin/../perl/lib";
6 use Fasta;
7 use Iterator::Fasta;
8 use File::Temp qw(tempfile);
9
10 my $file = shift;
11
12 if(! $file){
13     exit;
14 }
15
16 #set up names and variables
17 my $fasta_iterator = new Iterator::Fasta($file);
18
19 #write fastas here
20 my ($FA, $t_full) = tempfile;
21 while (my $fasta = $fasta_iterator->nextEntry()) {
22     my $def = Fasta::getDef(\$fasta);
23     my $seq_ref = Fasta::getSeqRef(\$fasta);
24
25     #fix non standard peptides
26     $$seq_ref =~ s/\*//g;
27     $$seq_ref =~ s/[^abcdefghiklmnpqrstvwyzxABCDEFGHIKLMNPQRSTVWYZX\-\n]/C/g;
28
29     #Skip empty fasta entries
30     next if($$seq_ref eq '');
31    
32     #reformat fasta, just incase
33     my $fasta_ref = Fasta::toFastaRef($def, $seq_ref);
34    
35     #build full file
36     print $FA $$fasta_ref;
37 }
38 close($FA); #close full file
39
40 #move finished files into place
41 system("mv $t_full $file");
Note: See TracBrowser for help on using the browser.