2871 days ago
Find the number of each 2 consecutive characters AA, AC,AG,AT,CC,CA... with Perl
#!/usr/bin/perl -w use strict; my $subject = "AACGTACTGACGTACTGGTTGGTACGA"; my %results = (); while ($subject =~ m/[ACTG...# matched text = $& if(exists $results{$&}) {...$results{$&} = 1; } } foreach (sort keys %results) {...2871 days ago
Generating a random string with Perl
#!/usr/bin/perl # This function generates random strings of a given length sub generate_random_string { my $length_of_ran...tring=shift;# the length of # the random string to generate m...gth_of_randomstring) { # rand @chars will generate a random #...2869 days ago
Needleman-Wunsch Algorithm in Perl
#!/usr/bin/perl # USAGE: perl nw.pl HEAGAWGHEE PAWHEAE BLOSUM50...."Biological sequence anaysis" Durbin et al. ed. CUP 1998, Pg. 1...nt die "usage: $0 \n" unless @ARGV == 4; # get sequences, m...f using fixed MATCH and MISMATCH scores we will use values read fro...2867 days ago
Count GC Content in nucleotide sequence with Perl
#!/usr/bin/perl -w ### Usage: get_gc_conte...--------- #Deal with passed parameters #--------------------...---------------------- if ($#ARGV == -1) { usage();...$out_file\n"; exit; } print "Parameters:\nfasta file =...} #finish up last line. &process_it; close(IN); close...2867 days ago
Implementation of biological random mutation with Perl
#!/usr/bin/perl -w use strict; use warnings; #sequence for a better recognition my $DNA="AAAAAAAAA...AAAAAAA \ n"; my $I; my $mutant; srand (time | $$). $mutant=mu...t "Here is the the original DNA: \ n"; print "$DNA \ n"; print "Here...2863 days ago
Perl script to generate a random psuedo DNA sequence !
#!/usr/bin/perl print "Enter a number of nucleotides: \n"; chomp ($N = ); @b=qw/A T G C/;print ">Genome\n";while($l2845 days ago
Perl script to extract lines with matching ids !!
#!/usr/bin/perl use strict; use warnings; my %patterns; #USAGE: perl extactByIds.pl Idsfile1 file2 > Result # Open file and get patterns to search for open(my $fh2,"2837 days ago
Perl script to extract fasta sequence by matching name/ids !!
#!/usr/bin/perl use strict; use warnings; use Text::Trim qw(trim); #Usage perl extractSeqbyID.pl ids.txt seq.fasta Result.fasta $ARGV[2] or die...hift @ARGV; my $fasta = shift @ARGV; my $out = shift @ARGV; m...$/ = "\n>"; open OUT, ">$out" or die; open FILE, "$fasta" or...2837 days ago
Perl script to find the absolute "full" path of the file !
#!/usr/bin/perl use Cwd; my $this_file_full_path = Cwd::abs_path(__FILE__); print "$this_file_full_path\n"; use Cwd qw/ realpath /; ## $0; this script my $path = realpath($0); print $path;2841 days ago