Devide psiblast out.pl

From Bioinformatikpedia
Revision as of 12:14, 21 May 2013 by Kalemanovm (talk | contribs) (Created page with "devide_psiblast_out.pl devides Psi-BLAST output file according to iterations. For example, if the original output file <code>psiblast-big-2iter</code> has results from two iterat…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

devide_psiblast_out.pl devides Psi-BLAST output file according to iterations. For example, if the original output file psiblast-big-2iter has results from two iterations, if will be split into two files psiblast-big-2iter_1 (first iteration) and psiblast-big-2iter_2 (second iterations). The files will be written into the same directory.

Usage

perl devide_psiblast_out.pl <psiblast output file>

Code

<source lang="perl">

  1. !/usr/bin/perl -w
  1. devide_psiblast_out.pl
  2. Devides a Psi-BLAST output file into separate files with the results of each iteration.

use strict;

my $out_p = $ARGV[0];

my $lines = ""; my @dev_lines = ();

open (READ, "$out_p") or die "could not open $out_p"; for my $line (<READ>) {

 $lines .= $line;

} @dev_lines = split(/Searching\.{50}/, $lines); close READ;

my $iter = $#dev_lines; my $header = $dev_lines[0]; for my $i (1..$iter){

 open (WRITE, ">" . $out_p . "_" . $i) or die "could not open $out_p" . "_" . "$i for writing";
 print WRITE $header . $dev_lines[$i];
 close WRITE;

}

  1. $i==1: header + first iteration results ... $i==$iter: header + last iteration results + footer

</source>