[Bio] / FigMetagenomeTools / rename_fa_qual.pl Repository:
ViewVC logotype

Annotation of /FigMetagenomeTools/rename_fa_qual.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : olson 1.1 #!/usr/bin/perl -w
2 :    
3 :     # rename the sequences in a fasta file and a quality file begining with 1.
4 :    
5 :     use strict;
6 :     use lib '/clusterfs/home/rob/perl';
7 :     use Rob;
8 :    
9 :     my $usage=<<EOF;
10 :     $0 <options>
11 :     -f fasta file
12 :     -q quality file (can be ommitted if it is -f.qual)
13 :     -s start at (default=1)
14 :     -d destination fasta file (default = -f.renamed). Quality file is named from this
15 :    
16 :     EOF
17 :    
18 :     my ($faf, $qaf, $daf, $start)=('','','',1);
19 :     while (@ARGV) {
20 :     my $t=shift;
21 :     if ($t eq "-f") {$faf=shift}
22 :     elsif ($t eq "-q") {$qaf = shift}
23 :     elsif ($t eq "-s") {$start = shift}
24 :     elsif ($t eq "-d") {$daf=shift}
25 :     }
26 :    
27 :     die $usage unless ($faf);
28 :     $qaf = $faf.".qual" unless ($qaf);
29 :     $daf = $faf.".renamed" unless ($daf);
30 :    
31 :     die "Fasta file $faf not found" unless (-e $faf);
32 :     die "Quality file $qaf not found" unless (-e $qaf);
33 :    
34 :    
35 :     my $seqs=Rob->read_fasta($faf);
36 :     my $qual=Rob->read_fasta($qaf, 1);
37 :    
38 :     open(FA, ">$daf") || die "Can't open $daf for writing";
39 :     open(QU, ">$daf.qual") || die "Can't open $daf.qual for writing";
40 :    
41 :    
42 :     foreach my $id (keys %$seqs) {
43 :     if ($qual->{$id}) {
44 :     $seqs->{$id}=~s/\s+//g;
45 :     print FA ">$start\n", $seqs->{$id}, "\n";
46 :     print QU ">$start\n", $qual->{$id}, "\n";
47 :     $start++;
48 :     }
49 :     else {
50 :     print STDERR "No qualitites for $id. Skipped\n";
51 :     }
52 :     }
53 :    
54 :     foreach my $id (keys %$qual) {
55 :     print STDERR "No fasta for quality $id\n" unless ($seqs->{$id});
56 :     }
57 :    
58 :     print STDERR "$start sequences were renamed\n";
59 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3