From: preecej Date: Thu, 3 Jul 2014 00:31:34 +0000 (+0000) Subject: ...and the post-exercise script for 1.pl X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=333854000c7071007c129a615ea37e2b000b8092;p=old-jaiswallab-svn%2F.git ...and the post-exercise script for 1.pl svn path=/; revision=578 --- diff --git a/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_1.after.pl b/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_1.after.pl new file mode 100644 index 0000000..c939ad4 --- /dev/null +++ b/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_1.after.pl @@ -0,0 +1,42 @@ +# Welcome to your first Perl script! Any line preceded with a '#' sign is a "comment". Perl ignores these lines; they are for human eyes only. + +# Except for this one... This line tells the computer to run this script (file) using Perl. +#!usr/bin/perl + +# -- VARIABLES -- + +# This is a variable "declaration"; it creates a variable and stores a value in it. +# Variables can hold words, numbers, and other data. You can change their value. This variable holds some sample DNA sequence. +my $test_sequence = "CCGATG"; + +# -- READING INPUT -- + +# Let's read in user input from the command line and assign it to a variable. +my $user_sequence = $ARGV[0]; + +# -- ANALYSIS AND PRINTING OUTPUT -- + +# The "print" statement will create output. +print "User sequence: " . $user_sequence . "\n"; + +# Make sure the user input is converted to upper-case for comparisons. +$user_sequence = uc($user_sequence); + +# Is this user-entered sequence the reverse complement of our test sequence? +my $reverse_sequence = reverse($user_sequence); +print "Reverse sequence: " . $reverse_sequence . "\n"; +my $reverse_complement = $reverse_sequence; +$reverse_complement =~ tr/ACGT/TGCA/; + +if ($reverse_complement eq $test_sequence) +{ + print "We have a match!\n"; + print $user_sequence . " is the reverse complement of " . $test_sequence . "\n"; +} +else +{ + print "No match.\n"; + print $user_sequence . " is NOT the reverse complement of " . $test_sequence . "\n"; +} + +# -- THE END -- \ No newline at end of file