2506 days ago
2463 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);2462 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);2460 days ago
2460 days ago
Collision free write with Perl
#Write into outfile -- collision free because of multicore usesage sub collision_free_write { my($...sg) = @_; open my $ofh, ">>", $outFile or die "$0 [$$]: open: $!";...$]: flock: $!"; print $ofh "$msg\n" or die "$0 [$$]: write: $!";...2455 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; # ind...tness; if ($individual->{survived}) { $survived++;...ift @_; my $pop_size = scalar @$population; # population...vate static variable @dictionary in closure for fitness() onl...2365 days ago
Convert newline formated sequence into fasta format with perl
use strict; use warnings; my $filename = $ARGV[0]; open(my $fh, '2364 days ago
Extract fasta sequence with Ids with Bash script
#!/bin/bash while IFS='' read -r line || [[ -n "$line" ]]; do echo "Text read from file: $line" samtools faidx ONT.fasta $line > $line.faa done < "$1"2348 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; $i2334 days ago