use warnings; use strict; #Check if there is an input of sequences if((scalar @ARGV)==0){ print "Please enter two sequences as arguments on the command line"; exit; } #get the input from command line my @two_seq=@ARGV; my $sequence=join('',@two_seq); #Remove newline and/or blank space between sequences chomp $sequence; $sequence=~s/^\n*$//g; $sequence=~tr/atcg/ATCG/; #Check if there are only two sequences entered if((scalar @two_seq)>2){ print "Sorry,no more than two sequences please.\nNote:Use space to seperate two sequences.\n"; exit; } #Check if two sequences are of the same length if((length $two_seq[0])!=(length $two_seq[1])){ print "Sorry, the two sequences you have just entered are of different lengths.\nPlease try again on the command line."; exit; } #Initialize joined sequences to be checked my @check_seq=split('',$sequence); #Compare reverse complement sequences for(my $i=0;$i<(length $sequence)/2;$i++) { #Start checking from both end of the sequence my $start_base=shift @check_seq; my $end_base=pop @check_seq; $end_base=~tr/ATCG/TAGC/; if($start_base eq $end_base){ next; }else{ print "Unfortunately, the two sequences are not reverse-complement.\n"; exit; } } #W reverse-complements print "Yes, the two sequences are reverse-complement of each other.\n"; exit;