tutorials:perl_examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:perl_examples [2010/08/03 02:23] – chkuo | tutorials:perl_examples [2017/04/12 17:27] (current) – chkuo | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Perl Examples | + | ====== Perl examples |
- | * Find empty files in a directory: [[tutorial: | + | * Find empty files in a directory: [[tutorials: |
- | * Unwrap sequences in fasta files: [[tutorial:perl:unwrap_seq_fasta.1.pl]] | + | * Rename |
- | * Find homopolymeric regions: [[tutorial: | + | |
- | * Generate Command Scripts for Running Blast+: [[tutorial: | + | |
- | * Execute Command Scripts: [[tutorial: | + | |
- | <code perl> | + | |
- | # | + | |
- | my $script_name = 'execute.3.pl'; | + | * Generate command scripts to run blast+: [[tutorials: |
+ | * Execute command scripts: [[tutorials: | ||
+ | * Parse blast+ results, 1 hit per line: [[tutorials: | ||
+ | * Parse blast+ results, 1 HSP per line: [[tutorials: | ||
- | # Chih-Horng Kuo < | + | * Unwrap sequences in fasta files: [[tutorials: |
- | # execute all .sh in the in_dir | + | * Find homopolymeric regions: [[tutorials: |
- | # v3 2010/02/04 | + | * Correct sequence orientation |
- | # style change | + | * Trim sequence based on lucy: [[tutorials: |
- | # v2 2009/ | + | * Trim sequence based on regex: [[tutorials: |
- | # v1 2006/05/03 | + | |
- | use strict; | ||
- | use warnings; | ||
- | |||
- | use Getopt:: | ||
- | |||
- | my $in_dir; | ||
- | my $exe_dir; | ||
- | my $in_file_ext; | ||
- | my $batch_file_ext; | ||
- | my $log_file_ext; | ||
- | my $prefix; | ||
- | my $n_job; | ||
- | my $debug; | ||
- | |||
- | GetOptions( | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | ); | ||
- | $prefix | ||
- | $in_file_ext | ||
- | $batch_file_ext = $batch_file_ext ? $batch_file_ext : ' | ||
- | $log_file_ext | ||
- | |||
- | system "mkdir -p $exe_dir" | ||
- | |||
- | my %job_id_HoA; | ||
- | my $count = 0; | ||
- | opendir( DIR, $in_dir ) or die " | ||
- | while ( defined( my $in_file = readdir(DIR) ) ) { | ||
- | if ( $in_file =~ / | ||
- | my $job_id = ( $count % $n_job ) + 1; | ||
- | push @{ $job_id_HoA{$job_id} }, $1; | ||
- | $count++; | ||
- | } | ||
- | } | ||
- | closedir(DIR); | ||
- | |||
- | foreach my $job_id ( sort keys %job_id_HoA ) { | ||
- | my $batch_file = $exe_dir . $prefix . $job_id . ' | ||
- | my $log_file | ||
- | open OUT, "> | ||
- | |||
- | # shell | ||
- | print OUT '# | ||
- | foreach my $file_id ( @{ $job_id_HoA{$job_id} } ) { | ||
- | print OUT " | ||
- | } | ||
- | |||
- | close OUT; | ||
- | system "chmod +x $batch_file"; | ||
- | system " | ||
- | print " | ||
- | } | ||
- | |||
- | exit(0); | ||
- | </ | ||
tutorials/perl_examples.1280773389.txt.gz · Last modified: by chkuo