Perlscr

From FreeBio

(Difference between revisions)

Revision as of 14:25, 3 November 2005

<per>

  1. !/usr/bin/perl -w

use strict; my $filename = 'sarsg.txt'; my $sarsl; my $sarsg; my $rcsarsg; my @sarsga; my $gcbases; my $gc;

  1. Open SARS genome file and read in the genome

open(FILE, $filename); #Open file containing SARS genome

while(<FILE>) {

$sarsg = $sarsg . $_;

}

print "$sarsg";


  1. calculate and print length of SARS genome

$sarsl =length $sarsg;

print "DNA from $filename :$sarsl\n";


  1. Make the reverse compliment of the sequence

$rcsarsg = reverse $sarsg;

$rcsarsg =~ tr/ATGCatgc/TACGtacg/;

print "\n Reverse compliment of $filename: $rcsarsg\n";


  1. GC content

@sarsga = split(, $sarsg);

$gcbases = 0;

my $base;

foreach $base (@sarsga) { if ($base eq 'G'){ ++$gcbases; } elsif ($base eq 'C'){ ++$gcbases; } } $gc = $gcbases / $sarsl; print"\nGC content in $filename: \n$gc\n";


  1. Find EcoRI restriction sites

if ($sarsg =~ /GAATTC/) { print "EcoRI restriction sites in $filename\n"; }


<per>