[ create a new paste ] login | about

Project: bioinformatics
Link: http://bioinformatics.codepad.org/nGQB5UZO    [ raw code | output | fork ]

proch - Perl, pasted on Mar 15:
# Let's put a sequence in the $sequence
# I wrote it in three lines just for clarity!
$sequence = 'ACACGTACGTACTACGTAGCTACGACGATCGTACGTAGCACTGAATTCGGACG';
$sequence.= 'ACGTACGTACGTACGTAGCTCGATCGACGTACGTAGCTAGCACAGCTAGCTGA';
$sequence.= 'CGACGTAGCTACGTACGTCACGAATTCGCGATCGTACGTAGCTGTACGACTAG';

# I write here a cutting site
$EcoRI_site = 'GAATTC';

# the "split" function breaks a string ($sequence) 
# when finding a particular 'pattern' ($EcoRI_site)

@fragments = split(/$EcoRI_site/, $sequence);

$total = $#fragments + 1;
print "There are $total fragments.\n\n";

foreach $fragment (@fragments) {
  $i++;
  $length = length($fragment);
  print "Fragment 1: $length bp\n";
}


Output:
1
2
3
4
5
There are 3 fragments.

Fragment 1: 42 bp
Fragment 1: 79 bp
Fragment 1: 26 bp


Create a new paste based on this one


Comments: