Calculate some statistics for a DNA alignment with Perl
...Bio::AlignIO; use Bio::Align::DNAStatistics; my $stats = Bio::Align::DNAStatistics->new(); my $alignin = Bio::AlignIO->new(-format => 'emboss',...2654 days ago
Extracting FASTA sequences based on position with perl script !!
...my $start = pop; local $/ = '>'; while () { chomp; next unless /(.+)/; my ($header) = "$/$1_$start-$end\n"; my $seq = ${^POSTMATCH}; $seq =~ s/\s//g;...2626 days ago
Transpose the file coordinates and plot dendrogram in R
#Save this as tr.awk { for (i=1; i2622 days ago
Extract fasta sequence from a multifasta file with coordinates
...# Simple access my $seqstr = $db->seq('CHROMOSOME_I', 4_000_000 => 4_100_000); my $revseq = $db->seq('CHROMOSOME_I', 4_100_000 => 4_000_000...path/to/fasta/files/'; print $sequences{'CHROMOSOME_I:1,20000'};2537 days ago
Extract fasta sequence from a multifasta file with fasta header Ids
...or die; while () { chomp; s/>//g; $select{$_} = 1; } close LIST; $/ = "\n>"; open O...= split (/\n/, $_); print OUT ">$_" if (defined $select{$id}); } close FASTA; close OUT;2523 days ago
2517 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);2473 days ago
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);2471 days ago
Collision free write with Perl
...$!"; flock $ofh, LOCK_EX or die "$0 [$$]: flock: $!"; print $ofh "$msg\n" or die "$0 [$$]: write: $!"; close $ofh or warn "$0 [$$]: close: $!"; }...2466 days ago
Genetic Algorithms demonstration with word DNA in Perl
...t "Mutated $old_dna to ", $individual->{dna}, "\n"; } } # this is a closure block! { # private static variable @dictionary in closure for fitness() only my @d...2376 days ago