2692 days ago
Extract ids from file with perl
#!/usr/bin/perl use strict; use warnings; my $fh=read_fh("fin.txt"); my %idHash; my $lastKey; while () { chomp $_; my @cells = split...2607 days ago
Extract fasta sequence from a multifasta file with fasta header Ids
#!/usr/bin/perl use strict; use warnings; #Usage: perl my $list = shift @ARGV; my $fasta = shift @ARG...or die; open FASTA, "$fasta" or die; while () { s/>//g; my ($id) = split...2517 days ago
Compress and decompress the sequence with perl
use strict; use warnings; my @char; while () { @char = split //; } comp(\@char); #--------------------- my $com= "r0a3m4a4j0"; my @com = split //, $com; dcomp (\@com); #dcomp sub here sub dcomp { my ($com_ref)=@_; my @com=@$com_ref; my $car; for (my $aa=0; $aa2514 days ago
2512 days ago
Calculate Dinucleotide Frequency with Perl
#!/usr/bin/perl -w use strict; my ($genome, $head, $tail); my (%mono_nt, %di_nt); $/ = ">"; open my $fasta, '2337 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);2467 days ago
Genetic Algorithms demonstration with word DNA in Perl
#!/usr/bin/perl -w # GA demonstration with word DNA (512 bits) use strict; use Data::Dumper; # individuals in t...frequencies hash (remember, all letters are uppercase) $freqs{$_}++ foreach split...2371 days ago
Perl script for calculate Levenshtein distance
sub levenshtein_dist { my ($str1, $str2) = @_; my ($len1, $len2) = (length $str1, length $str2); if ($len1 == 0) { return $len2; } if ($len2 == 0) { return $len1; } my %mat; for (my $i = 0; $i2339 days ago
Reformat the file names with Perl
#!/usr/bin/perl use strict; use warnings; use File::Copy qw(copy);; $| = 1; my...t if $. == 1; my ($lichenName, $name, $code) = split /\s+/, $line; next unl...files){ $files[$_] =~ s/\.scf$//; my @pName = split...2335 days ago