Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use strict;
- no warnings "recursion";
- my %ISFET_currents;
- my $searchdir;
- my $outfile;
- unless(defined($ARGV[0]) && defined($ARGV[1])) {
- print "Parsing ISFET-2007 transconductance IV curve data files\
- \tsearches in folders recursively starting from specified \"root\" folder\
- \tFoldername => must be ISFET number (device was marked)\
- \tOutput file => to write parsed data\n\
- Data processing:\n\
- \t-find current values at Ugs = 5V\
- \t-find out about the pH of buffer in filename(if recorded)\
- \t-check wheather channel currents meet 350..650 uA range\
- \t-find difference between currents in channels\
- \t-say OK for using if remained ISFETS meet less than 60 uA difference\n\n";
- print "Usage:\t./current_script searchdir output_filename\n\n";
- exit;
- }
- chomp($searchdir = $ARGV[0]);
- chomp($outfile = $ARGV[1]);
- open(DATA_FILE, ">>$outfile") ||
- die "Can't open $outfile: $!";
- parse_dir($searchdir);
- foreach my $ISFET (sort keys %ISFET_currents) {
- if(($ISFET_currents{$ISFET}) < 60 ) {
- print DATA_FILE "\nISFET #$ISFET Current diff = $ISFET_currents{$ISFET}";
- print DATA_FILE " OK";
- }
- }
- close(DATA_FILE);
- sub parse_dir {
- my $searchdir = shift;
- my $ISFET_num = $searchdir;
- $ISFET_num =~ s{.*/}{};
- opendir(DIR, $searchdir) ||
- die "\nCan't open $searchdir: $!";
- my @files = readdir(DIR);
- closedir(DIR);
- foreach my $current_file (@files) {
- next if $current_file =~ m/^\.\.?$/;
- if ( $current_file =~ m/ugs/i ) {
- my $pH_data;
- if( $current_file =~ m/pH((\d+)[_.]?(\d+))/gi ) {
- $pH_data = 'pH' . $1;
- }
- open(CUR_FILE, "<$searchdir/$current_file") ||
- die "Can't open $current_file: $!";
- my @iv_lines= <CUR_FILE>;
- my($Ugs, $Uds, $I0, $I1) = iv_check(@iv_lines);
- my $I_diff = abs($I0 - $I1);
- $I_diff =~ s/(.\d\d)\d+/$1/g;
- if(($I0 < 350 || $I0 > 650 ) ||
- ($I1 < 350 || $I1 > 650 )) {
- print DATA_FILE "\n=============================\
- \nFile: $current_file\
- \nISFET = $ISFET_num\
- \nChannel current is not in range 350..650 uA\
- \nChannel currents I = $I0, $I1 uA
- \nVoltage Ugs = $Ugs\n\
- $pH_data\n";
- } else {
- $ISFET_currents{$ISFET_num} = $I_diff;
- print DATA_FILE"\n===============================\
- \nFile: $current_file\
- \nISFET = $ISFET_num\
- \nVoltages:\
- \n\tUgs = -$Ugs\
- \n\tUds = -$Uds\
- \nCurrents:\
- \n\tI0 = $I0\
- \n\tI1 = $I1\
- \n\tDifference = $I_diff\n";
- }
- close(CUR_FILE);
- }
- if ( -d "$searchdir/$current_file" ) {
- parse_dir("$searchdir/$current_file");
- }
- }
- }
- sub iv_check {
- my @lines = @_;
- my @iv_checked;
- foreach my $line (@lines) {
- next unless $line =~ m/^(\d\.\d{2})
- (?>\s+)
- (\d\.\d{2})
- (?>\s+)
- (\d+\.\d{2})
- (?>\s+)
- (\d+\.\d{2})
- /xgi;
- my $Ugs = $1;
- my $Uds = $2;
- my $I0 = $3;
- my $I1 = $4;
- if( $Ugs > 4.90 && $Ugs < 5.20) {
- push @iv_checked, $Ugs, $Uds, $I0, $I1;
- return @iv_checked;
- }
- }
- }
Add Comment
Please, Sign In to add comment