From: preecej Date: Thu, 3 Jul 2014 00:29:30 +0000 (+0000) Subject: Added STEM 2014 camp scripts. Draft stage. X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=8c999e783d286711cc834a28e4c7a407ee6804da;p=old-jaiswallab-svn%2F.git Added STEM 2014 camp scripts. Draft stage. svn path=/; revision=577 --- diff --git a/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_1.pl b/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_1.pl new file mode 100644 index 0000000..13017fc --- /dev/null +++ b/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_1.pl @@ -0,0 +1,31 @@ +# 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"; + +# Does the user sequence exactly match the test sequence? +if ($user_sequence eq $test_sequence) +{ + print "We have a match!\n"; + print $user_sequence . " is equivalent to " . $test_sequence . "\n"; +} +else +{ + print "no match"; +} diff --git a/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_2.pl b/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_2.pl new file mode 100644 index 0000000..ac1afb3 --- /dev/null +++ b/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_2.pl @@ -0,0 +1,27 @@ +#!usr/bin/perl + +# Introduce loops and functions. Concept focus: Iteration, modularization. More string manipulation: parsing, identifying, counting sequence snippets. + +# this is a function. you can call it many times +sub lookup($) { + my $motif = $ARGV[0]; + print "Is $motif found in $_[0]? "; + if ($_[0] =~ /$motif/) { + print "Found it!\n"; + print "How many times?"; + # the hard way (a loop) + # the easy way (regular expression pattern-matching and countings) + } + else { + print "Nope...\n"; + } +} +# end of function + + +# main body of code +my $seq = "ACGTGGCGCCGGCGCCATATATTTA"; + +print "My sequence: " . $seq . "\n"; + +lookup($seq); diff --git a/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_3.pl b/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_3.pl new file mode 100644 index 0000000..1b90661 --- /dev/null +++ b/Personnel/preecej/perl_singletons/STEM_2014/STEM_2014_Script_3.pl @@ -0,0 +1,32 @@ +#!usr/bin/perl + +# Motif-finding using Lol's Vrs1/vrs1 barley samples. Will include file I/O and loops (for reading in sequence lines and for counting motifs). +# Concept focus: A lot of biology data is stored in files and databases. We can read those files and databases to get data, analyze it with our code, +# and generate new information as file, database, and/or image output. Read sequence data from files, locate feature(s), output information about those locations. + +# this is a function. you can call it many times +sub lookup($) { + my $motif = "ACG"; + print "Is $motif found in $_[0]? "; + if ($_[0] =~ /$motif/) { + print "Found it!\n"; + } + else { + print "Nope...\n"; + } +} +# end of function + + +# main body of code +my $seq = "ACGT"; +print "My sequence: " . $seq . "\n"; +lookup($seq); + +my $rev_seq = reverse($seq); +print "Reversed: " . $rev_seq . "\n"; +lookup($rev_seq); + +$more_seq = $seq . "CCGAAT"; +print "Longer sequence: " . $more_seq . "\n"; +lookup($more_seq);