#! /usr/bin/perl -w #Script was written by CSR on 10.27.08 #Input = Sequences in FASTA format. #Ouput = Sequences (fasta format) with a tag added to the header line. #Note: Insert a tag between the ID and description, i.e. (id {tag} description). #Usage = ./tag_fasta_header1.0.pl -i [input filename] -o [output filename] -t [tag] use strict; use Bio::SeqIO; use Getopt::Std; my %args; getopts('i:o:t:', \%args); my $usage = "Warning, missing information...\nUsage is: ./tag_fasta_filename.pl -i [infile] -o [outfile] -t [tag]\n"; my $infile; my $outfile; my $tag; #command line arguments if ($args{i}) { $infile = $args{i}; } else { die "$usage"; } if ($args{o}) { $outfile = $args{o}; } else { die "$usage"; } if ($args{t}) { $tag = $args{t}; } else { die "$usage"; } #load the input (fasta) file my $in = Bio::SeqIO-> new(-format => 'fasta' , -file => $infile); #open the output file open (OUTPUT , "> $outfile") or die "COULD NOT OPEN THE OUTPUT FILE\n"; #break each fasta sequence into its parts while( my $seqobj = $in->next_seq ) { my $id = $seqobj->display_id; my $desc = $seqobj->description(); my $seq = $seqobj->seq; #add a tag print OUTPUT ">$id {$tag} $desc\n"; print OUTPUT "$seq\n\n"; } close (OUTPUT);