2569 days ago
2526 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);2525 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);2523 days ago
2523 days ago
Collision free write with Perl
#Write into outfile -- collision free because of multicore usesage sub collision_free_write { my($outFile, $msg) = @_...$!"; print $ofh "$msg\n" or die "$0 [$$]: write: $!"; close $ofh...2518 days ago
Genetic Algorithms demonstration with word DNA in Perl
.../perl -w # GA demonstration with word DNA (512 bits) use strict; use Data::Dum...on array sub evaluate_fitness { my $population = shif...have at least one individual with # parent > 0 my $indi...= 0; # start with 0 fitness my $max_entry_length =...2428 days ago
Convert newline formated sequence into fasta format with perl
use strict; use warnings; my $filename = $ARGV[0]; open(my $fh, '2427 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"2411 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; $i2397 days ago