#!/usr/local/bin/perl -w $| = 1; #generate promoters my $Bases = "ACGT"; #my @PromoterLenghts = ($PromoterMinLenght...$PromoterMaxLength); my @PromoterLenghts = (4); my $PromotroListLength = $#PromoterLenghts; $PromotroListLength ++; #unlink 'permute.txt'; my ($currLenght, $permutelist_filename); foreach $currLenght (@PromoterLenghts){ $permutelist_filename = &permute_bases ($currLenght, $Bases); } #print "Sequences file $permutelist_filename\n"; open (PIN, "permute.txt")||die "Can't open file: $!\n"; open (OUTPUT, ">output.txt")||die "Can't open file: $!\n"; while (){ $promoter = $_; chomp $promoter; #do intrestering stuff with promoter sequence print OUTPUT "$promoter\n"; } close PIN ||die "Could not close sequences file: $!"; close OUTPUT ||die "Could not close output file: $!"; unlink 'permute.txt'; ##################################################################### sub permute_bases { my( $length, $bases )= @_; my @bases= split //, $bases; my @digit= (0) x $length; my $seq= $bases[0] x $length; my $permutelist_filename = "permute.txt"; open (PERMUTEOUT, ">>$permutelist_filename"); while( 1 ) { print PERMUTEOUT $seq,$/; print $seq,$/; my $pos= 0; while( @bases <= ++$digit[$pos] ) { substr( $seq, $pos, 1 )= $bases[ $digit[$pos]= 0 ]; return if $length <= ++$pos; } substr( $seq, $pos, 1 )= $bases[ $digit[$pos] ]; } close PERMUTEOUT||die"Could not close $permutelist_filename: $!"; return ($permutelist_filename); }