Skip to content

Instantly share code, notes, and snippets.

@davfre
Created November 14, 2012 07:25
Show Gist options
  • Save davfre/4070803 to your computer and use it in GitHub Desktop.
Save davfre/4070803 to your computer and use it in GitHub Desktop.
Test script for AppliedProgramming course, Exercise 6
use Test::More tests => 15;
use Pattern;
use Restriction;
use strict;
use warnings;
# sequences for testing
my $testsequence0 = "AAAAAAAAAACGATCTAAAAAAA" ; #should not match
my $testsequence1 = "AAAAAAAAAAAGATCCAAAAAAA" ; #should match
my $testsequence2 = "AAAAAAAAAAGGATCTAAAAAAA" ; #should match
my $testsequence3 = "AAAAAAAAAAGGATCTCCCCCCCGGATCTAAAAAAA" ; #should match and has two restriction sites
my $testsequence4 = "ATCTAAAAAAAAAAAAAAAAAGG" ; #should only work if marked circular
my $testpattern = "[AG]GATC[TC]" ;
my @matchStart;
#start position for non-circular cases
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence0,
'pattern' => $testpattern);
is(@matchStart, 0);
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence1,
'pattern' => $testpattern);
is($matchStart[0], 11);
is(scalar(@matchStart), 1);
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence2,
'pattern' => $testpattern);
is($matchStart[0], 11);
is(scalar(@matchStart), 1);
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence3,
'pattern' => $testpattern);
is($matchStart[0], 11);
is($matchStart[1], 24);
is(scalar(@matchStart), 2);
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence4,
'pattern' => $testpattern);
is(@matchStart, 0);
#start pos of matches for circular sequences
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence0,
'pattern' => $testpattern,
'is_circular' => 'Yes');
is(@matchStart, 0);
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence1,
'pattern' => $testpattern,
'is_circular' => 'Yes');
is($matchStart[0], 11);
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence2,
'pattern' => $testpattern,
'is_circular' => 'Yes');
is($matchStart[0], 11);
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence3,
'pattern' => $testpattern,
'is_circular' => 'Yes');
is($matchStart[0], 11);
is($matchStart[1], 24);
@matchStart = Pattern::getPatternMatchPositions('sequence' => $testsequence4,
'pattern' => $testpattern,
'is_circular' => 'Yes');
is($matchStart[0], 22);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment