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

View of /FigMetagenomeTools/rename_fa_qual.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.2 - (download) (as text) (annotate)
Fri Mar 16 20:51:25 2007 UTC (13 years, 2 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, mgrast_rel_2008_0806, mgrast_dev_10262011, mgrast_dev_02212011, mgrast_rel_2008_0923, mgrast_release_3_0, mgrast_dev_03252011, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, mgrast_rel_2008_0919, mgrast_rel_2008_1110, myrast_33, mgrast_rel_2008_0917, mgrast_dev_04052011, mgrast_dev_02222011, HEAD
Changes since 1.1: +0 -1 lines
initial tweaks

#!/usr/bin/perl -w

# rename the sequences in a fasta file and a quality file begining with 1.

use strict;
use Rob;

my $usage=<<EOF;
$0 <options>
-f fasta file
-q quality file (can be ommitted if it is -f.qual)
-s start at (default=1)
-d destination fasta file (default = -f.renamed). Quality file is named from this 


my ($faf, $qaf, $daf, $start)=('','','',1);
while (@ARGV) {
 my $t=shift;
 if ($t eq "-f") {$faf=shift}
 elsif ($t eq "-q") {$qaf = shift}
 elsif ($t eq "-s") {$start = shift}
 elsif ($t eq "-d") {$daf=shift}

die $usage unless ($faf);
$qaf = $faf.".qual" unless ($qaf);
$daf = $faf.".renamed" unless ($daf);

die "Fasta file $faf not found" unless (-e $faf);
die "Quality file $qaf not found" unless (-e $qaf);

my $seqs=Rob->read_fasta($faf);
my $qual=Rob->read_fasta($qaf, 1);

open(FA, ">$daf") || die "Can't open $daf for writing";
open(QU, ">$daf.qual") || die "Can't open $daf.qual for writing";

foreach my $id (keys %$seqs) { 
 if ($qual->{$id}) {
  print FA ">$start\n", $seqs->{$id}, "\n";
  print QU ">$start\n", $qual->{$id}, "\n";
 else {
  print STDERR "No qualitites for $id. Skipped\n";

foreach my $id (keys %$qual) {
 print STDERR "No fasta for quality $id\n" unless ($seqs->{$id});
print STDERR "$start sequences were renamed\n";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3