#!/usr/bin/perl # repeat_classer2.pl # usage: rep_classer2.pl rep_units.txt # run this script before repeatalyzer.pl # detects what macroclass each repeat belongs to # rep_units.txt is a list of all distinct types of repeats in the db # Perseus Missirlis - Mar 18, 2004 use strict; my $rep = "rep_class.txt"; unless ( open(REP_CLASS, ">$rep") ) { die "Cannot open file \"$rep\" to write to!\n\n"; } my $i = 1; while (<>) { chomp; if ($_ =~ /(\S+)/) { print "line $i matched: $1\n\n"; my @units; my $rep_class; my @repeat = split('',$1); my $lengther = scalar @repeat; my $n; print "this is the repeat: @repeat\n"; print "this is the length of the repeat: $lengther\n\n"; my $x; while ($n < $lengther) { my $for = shift @repeat; $repeat[($lengther - 1)] = $for; my $for_run = "@repeat"; $for_run =~ s/\s//g; my $rev_run = reverse $for_run; $rev_run =~ tr/ATGCatgc/TACGtacg/; print "this is the repeat after popping it: @repeat\nthis is the variable for regex: $for_run\nthis is the variable in reverse: $rev_run\n\n"; $units[$x] = $for_run; $x++; $units[$x] = $rev_run; $x++; $n++; } print "this is the units array: @units\n"; @units = sort(@units); print "sorted units:\n"; foreach my $unit(@units) { print $unit . "\n"; $rep_class .= $unit . "o"; } $rep_class = "o" . $rep_class; print "this is the rep_class: $rep_class\n\n"; print REP_CLASS $rep_class . "\n"; $i++; } } close(REP_CLASS); exit; ############## # End script # ##############