Monday, 27 June 2011

Deparse an ABI file...

#!/usr/bin/perl -w

use strict;

my $stadenApp = "~/staden-linux-1-6-0/linux-bin/getABIfield";


for my $inputFile (@ARGV){
unless($inputFile =~ /\/(KN654-BAC(\d\d)-(\d\d)_([A-H]\d\d)-(FP|RP))\.ab[1i]$/){
warn "ignoring $inputFile\n";
next;
}

my $fileName = $1;
my $wellId = $4;
open APP, "-|", "$stadenApp -a -t $inputFile"
or die "failed to exec $stadenApp : $!\n";
my %data;
while(){
## Skip some 'data rows' that we can ignore for now.
next unless
/^$inputFile (\S{4}) (\d+) (.*)$/;
chomp;
$data{"$1 $2"} .= $3;
}
if (keys %data == 0){
die "wha? \n"
}
print
join("\t",
$fileName,
$data{"SMPL 1"}, # Trace name (unique id)
$data{"RunN 1"}, # Run name
$wellId,
$data{"TUBE 1"}, # Well id
$data{"GTyp 1"}, # Polymer name
$data{"MCHN 1"}, # Instrument name
$data{"MODL 1"}, # Instrument model
$data{"PDMF 1"}, # Mobility file
$data{"CMNT 1"}, # Comment
## Signal to noise ratio for the 4 dyes
split(/ /, $data{"S/N% 1"}),
## Times of the various 'events'
$data{"RUND 1"}. " ". $data{"RUNT 1"},
$data{"RUND 2"}. " ". $data{"RUNT 2"},
$data{"RUND 3"}. " ". $data{"RUNT 3"},
$data{"RUND 4"}. " ". $data{"RUNT 4"},
## More...
$data{"APrV 1"}, # Analysis protocol version number
$data{"CTNM 1"}, # Plate Name
$data{"CTID 1"}, # Plate barcode
$data{"ASPt 1"}, # Basecall start scan
$data{"AEPt 1"}, # Basecall stop scan
$data{"SPAC 1"}, # Base spaceing
), "\n";
}

No comments: