Count the number of N in fasta file with Perl
#!/usr/bin/perl my ($h, $n, $l); open(I,$ARGV[0]) or die($!); while(){ chomp; if(/^>/){ $h=substr($_,1); }else{ $n=($_=~tr/nN/nN/); $l=length($_); print $h,"\t",$l,"\t",$n,"\t",$n/($l-$n),"\n"; } } close(I);2480 days ago
Extract the fastq sequence with range in Perl
use Bio::DB::Fasta; open(POSITIONS,"positions.txt"); while(){ chomp; my ($seqName,$begin,$end) = split(/\s/); my $db = Bio::DB::Fasta->new('allGenomeContacted.fa'); my $seq = $db->seq("$seqName", $begin => $end); print "$seq\n"; } close(POSITIONS);2482 days ago
2480 days ago
Collision free write with Perl
...($outFile, $msg) = @_; open my $ofh, ">>", $outFile or die "$0 [$$]: open: $!"; flock $ofh, LOCK_EX or die "$0 [$$]: flock: $!"; print $ofh "$msg\n" or die "$...2475 days ago
Genetic Algorithms demonstration with word DNA in Perl
...yte-1, 8) |= int(rand(256)); } $individual->{dna} = $new_dna; # print "Mutated $old_dna to ", $indi...n sub byte_to_letter { my $dna = shift @_; my $byte = shift @_; # print "Got byte $byte\n"; my $let...2386 days ago
Convert newline formated sequence into fasta format with perl
use strict; use warnings; my $filename = $ARGV[0]; open(my $fh, '2384 days ago
Clump Finding Problem Solved with Perl
...CGAATGTAATGTGCCTATGGC"; my $subStr="?"; my $clump=4; my $kmer=5; for (my $aa=0; $aa $max) { $max = $km;} #print "$km\t$myStr\n"; $myHash{$myStr}=$km; } #Print all key which have matching v...2348 days ago
Reformat the file names with Perl
#!/usr/bin/perl use strict; use warnings; use File::Copy qw(copy);; $| = 1; my %hash; my @files = glob "*.scf"; if (!$ARGV[0]){ print "Table file needed\n USAGE: $0 tab...2350 days ago
Fill up the form and blast with perl
...rm_name => 'myForm', fields => { 'Algorithm' => 'blastx', 'BlastTargetSet' => 'ATH1_pep', 'QueryText' => $sequence, }, ); print $mech->content;2339 days ago
Insert the sequence at desire location in multi-fasta file with Perl
#!/usr/bin/perl use warnings; use strict; use Bio::SeqIO; use Bio::Seq; use File::Copy; #ARGV[0] should be in following format --- Keep the coordinate sorted...2328 days ago