Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Extract a random sequence from a file

  • Public
By Abhi 3120 days ago
#!/usr/local/bin/perl -w use strict; use warnings; use autodie; use List::Util qw/ shuffle /; my $outputfile = 'randomoutput.txt'; open my $in_fh, '<', 'seq1.fa'; open my $out_fh, '>', $outputfile; my $size = 21; my $count = 10; while (my $line = <$in_fh>) { next unless $line =~ /^([ATGCN]+)/; my $genome = $1; my $len_genome = length $genome; my @start_points = shuffle(0 .. $len_genome-$size); next unless @start_points >= $count; print substr($genome, $_, 21), "\n" for @start_points[0 .. $count-1]; }