1
###############################################################################
3
#Jianwen Fang (jwfang1999@yahoo.com)
5
#THis program returns reverse complement sequences of all sequences in the current directory
6
#and save them in the same directory, using the same name with extension ".rev"
7
###############################################################################
23
#GenBank GenBank format
25
#raw Raw format (one sequence per line, no ID)
27
my @format = ('Fasta', 'EMBL', 'GenBank', 'GCG', 'Raw');
29
print("\nWhat is the format of the original sequence files?\n");
30
print("type 0 for Fasta; 1 for EMBL; 2 for GenBank; 3 for GCG; 4 for Raw\n");
31
$inputFormat = <STDIN>;
34
print("\nWhat is the format of the reverse complement sequence files you want?\n");
35
print("type 0 for Fasta; 1 for EMBL; 2 for GenBank; 3 for GCG; 4 for Raw\n");
36
$outputFormat = <STDIN>;
37
chomp ($outputFormat);
39
unless(opendir(FOLDER, $folder))
41
print "cannot open folder $folder!\n";
45
@files = grep(!/^\.\.?$/, readdir(FOLDER));
47
foreach my $file (@files)
56
print "$numSeq reverse complement sequences have been saved in current directory\n";
59
############################################################################
60
#subroutine getRevcom take an backward sequence file name(should with .seq extension) as parameter
61
#return its revcom sequence using the same name with the extension replaced with rev
62
############################################################################
66
my $in = Bio::SeqIO->new('-file'=>$seqFile, '-format'=>$format[$inputFormat]);
67
my $seq = $in->next_seq();
68
my $revcomSeq = $seq->revcom();
69
my @outSeqFile = split (/\./, $seqFile);
71
push(@outSeqFile, 'rev');
72
my $outSeqFile = join('.', @outSeqFile);
73
print "$outSeqFile\n";
74
my $out = Bio::SeqIO->new('-file'=>">$outSeqFile", '-format'=>$format[$outputFormat]);
75
$out->write_seq($revcomSeq);