Here we are going to first build a weight matrix using sequences from exon-intron donor splice sites and then use the matrix to scan for exon-intron borders. This could be used together with an acceptor splice site scanner as part of a gene predictor.
Given a file with a set of donor splice sites and a sequence to scan the following process is required:
cd perlCourse
mkdir pswmand change into it:
cd pswm
mkdir binand one named data:
mkdir data
chmod u+x bin/makeWeightMatrixSave the donorSpliceSites.seq file in the data directory. You do not have to change the permissions on this file.
kate bin/makeWeightMatrix &
bin/makeWeightMatrix data/donorSpliceSites.seqThis should give you some error messages, which you now have to fix. Always start with the first one, fix it, and then rerun to see if fixing it also fixed the other error messages
less data/donorSpliceSites.seqIn less use
q to quit. Is the output what you would expect? Perl can not find all bugs in your program automatically (bugs are errors in the program). Find the bug and fix it. It is often usefull to print out the values of variables at different places in the program to check if the values are what you would expect
my, foreach, while, chomp, uc, chop, keys, sort, print?
$nuc is declared (my $nuc) several times in the code. What is the scope of each of these declarations?
bin/makeWeightMatrix data/donorSpliceSites.seq > donor.pswm
bin/scanSequenceWithWeightMatrix AGAGT donor.pswmIt is usually a good idea to test with a short example before using a longer one. On linux machines the keyboard combination
ctrl- c stops a program.
print "1\n"; at strategic places throughout the script (using a different number for each line). A good place is usually right after the { starting a block of code. Then rerun the script and see if it prints out what you would expect. Printing out the contents of a variable can also help. Chancing the print statements to print "1: $_\n"; will print out the number and the contents of the $_ variable. Use this to track down the bug
while loop in the script reads the position specific weight matrix (pswm) made by the previous script. This part of the code is highly redundant, write a sub routine which will read the weights for one position in the matrix and return a hash with the scores. Using this the first if statement becomes:
if ($_ eq "Position 1") {
%pswm1 = readMatrixColumn();
}
What is the difference between last and return?
Would it have been easier to fix the bug in the previous step if you had rewritten the code first?
@ARGV array (Line 7), and where does it come from? Why is it not necessary to declare @ARGV with my before it is used, and why is the name the array in uppercase letters? What does shift do? Try printing the contents of @ARGV before and after the my $sequence = shift @ARGV; line.
$score += $pswm1{substr($sequence, $pos-1, 1)};
$score += $pswm2{substr($sequence, $pos, 1)};
$score += $pswm3{substr($sequence, $pos+1, 1)};
$score += $pswm4{substr($sequence, $pos+2, 1)};
$score += $pswm5{substr($sequence, $pos+3, 1)};
Why is it necessary to subtract one from $pos in the first line?
$minScoreCutoff used for?
<> operator. Why is it usefull to read input at more than one place in the script?
$minScoreCutoff then sub routine should print out the position and the score in this format (BED):
chr2 position position donor scoreWrite
chr2 and donor literally. Position should be the sequence position plus 219264478 (to make it the genomic position) and score is the weight matrix score.
$minScoreCutoff = 5 and scan the full CTDSP1 gene for donor sites:
bin/scanSequenceWithWeightMatrix "sequence" donor.pswm > CTDSP1_donorSites.bedUse
less to look at the output:
less CTDSP1_donorSites.bedDoes the output look like expected?
genome browser in the upper left corner. In the My Data drop down menu select Custom tracks. Copy/paste your results into the data box. Press the Submit button and click on go to genome browser. Copy/paste chr2:219264478-219270664 into the position box and press go. Compare the User Track to the exon intron annotation of the CTDSP1 gene. Does the weight matrix give good predictions?