forked from sjackman/fastascripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
farc
executable file
·39 lines (32 loc) · 680 Bytes
/
farc
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
#!/usr/bin/perl
# Reverse and complement the sequences
# Copyright 2013 Shaun Jackman
use strict;
use Getopt::Std qw'getopts';
my %opt;
getopts 'f:r:', \%opt;
my $opt_f = $opt{'f'};
my $opt_r = defined $opt{'r'} ? $opt{'r'} : '';
while (<>) {
next if /^#/;
die unless /^>/;
chomp;
my ($id, $comment) = split ' ', $_, 2;
my $seq = '';
while (<>) {
next if /^#/;
last if /^>/;
chomp;
$seq .= $_;
}
if (defined $opt_f) {
print $id, $opt_f, "\n", $seq, "\n";
}
if (defined $opt_r) {
$seq = reverse($seq);
$seq =~ tr/ACGTMRWSYKVHDBNacgtmrwsykvhdbn/TGCAKYWSRMBDHVNtgcakywsrmbdhvn/;
print $id, $opt_r, "\n", $seq, "\n";
}
redo if /^>/;
last if eof;
}