-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrevfasta.pl
executable file
·46 lines (37 loc) · 1.02 KB
/
revfasta.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env perl
####################
# revfasta.pl - given fasta format file, rev seqs.
# uses Bioperl
# By Madelaine Gogol
# 10/2008
####################
use strict;
use Bio::SeqIO;
my ($rev,$defline,$sequence,$count,$in,$elements_to_print);
$in = Bio::SeqIO->new(-file=>"$ARGV[0]", -format=>'Fasta');
while(my $seq = $in->next_seq())
{
$sequence = $seq->seq();
$defline = $seq->display_id();
$rev = reverse($sequence);
print ">$defline\n$rev\n";
}
######################################################
# subroutine get_file_data
# arguments: filename
# purpose: gets data from file given filename;
# returns file contents
######################################################
sub get_file_data
{
my($filename) = @_;
my @filedata = ();
unless( open(GET_FILE_DATA, $filename))
{
print STDERR "Cannot open file \"$filename\": $!\n\n";
exit;
}
@filedata = <GET_FILE_DATA>;
close GET_FILE_DATA;
return join('',@filedata);
}