Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # Program to parse kinetic data produced by the plate reader at Couchin lab.
- # The data structure is not complicated, but almost impossible to extract data manually:
- # one line contains all data for the 96 wells in each time step.
- # What the program does is to collect the absorbance value correspondig to each well for each timestep and makes a table
- # Usage:
- # $./Kinetic_parser.pl <Infile> >Outfile
- # (c) Daniel Suveges
- # v 1.0 2011.09.30
- # Very primitive form, but works anyway
- # v 2.0 2011.10.04
- # Trained to get all possible 96 well data, but returns only those that actually filled
- # Cleaning input data is not required
- # v 2.5 2013.06.28
- # An error is fixed: real labeling of the wells.
- # Deals with multiple experiments!!!
- # Time format is in minutes with decimal values instead of the min:sec format
- our $version = "2.5";
- use strict;
- use warnings;
- my @lines = ();
- our %AllData = ();
- my @time = ();
- # REadin the files line by line
- foreach (<>){
- # A line can be separeted by \r or \n
- push(@lines,split(/[\r\n+]/,$_));
- }
- my $lineNo = "";
- my $time = "";
- foreach my $line (@lines){
- # print "$line!!\n";
- # my $time = "";
- if ($line =~ /(\d+\:\d+)\t([\d\.]+)([\d\.\t]+)/){
- $lineNo = "0";
- &row($lineNo,$3);
- my ($min, $sec) = split(/:/,$1);
- $time = $min + (int($sec / 0.6)/100);
- push (@time, $time);
- }
- elsif ($line =~ /^\t([\d\t\.]+\d)/){
- $lineNo ++;
- &row($lineNo,$1);
- }
- else {
- next;
- }
- }
- print "Time\t";
- my @keys = keys %AllData;
- foreach my $keys (@keys){
- print "$keys\t"
- }
- print "\n";
- for ( my $i = 0; $i < scalar @{$AllData{$keys[0]}}; $i++){
- print "$time[$i]\t";
- foreach my $keys (keys %AllData){
- print "${$AllData{$keys}}[$i]\t";
- }
- print "\n";
- }
- # parsing a row of the outputfile
- sub row {
- my $LineNo = $_[0];
- my $line = $_[1];
- my @stuff = split(/\t/, $line);
- my @letters = qw(A B C D E F G H);
- # Reading all lines. Every line is a timestep with data correspondig to all 96 well
- for( my $index = "0"; $index <= scalar (@stuff); $index++){
- # If the element is exists, let's see which well is it?.
- if($stuff[$index]){
- #Find the position in the plate
- # Find the row (A-H)
- my $row = $letters[int($index/12)];
- # Find the column (1-12)
- my $column = $index % 12;
- push(@{$AllData{$row.$column}},$stuff[$index]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement