Created
September 4, 2009 00:25
-
-
Save anonymous/180628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert well number to well string | |
# jcline@ieee.org | |
# Returns: | |
# string if success | |
# "" if error | |
# | |
sub wellNumberToString { | |
my $n = $_[0]; # number | |
my $size = $_[1] || 96; # size of plate | |
my $orient = $_[2] || "L"; # Landscape or Portrait orientation | |
my $col; | |
my $row; | |
my $s; | |
if ($n < 1) { | |
return ""; | |
} | |
elsif ($n <= 96 && $size == 96) { | |
if ($orient eq "P") { | |
$row = int(($n-1) / 12) + 1; | |
$col = ($n - (($col - 1) * 12)); | |
} | |
elsif ($orient eq "L") { | |
$col = int(($n-1) / 8) + 1; | |
$row = ($n - (($col - 1) * 8)); | |
} | |
$s = sprintf "%c", 64+$row; # I bet no one has EBCDIC anymore | |
$s =~ s/@/H/; | |
} | |
elsif ($n <= 384 && $size == 384) { | |
if ($orient eq "P") { | |
$row = int(($n-1) / 24) + 1; | |
$col = ($n - (($col - 1) * 24)); | |
} | |
elsif ($orient eq "L") { | |
$col = int(($n-1) / 16) + 1; | |
$row = ($n - (($col - 1) * 16)); | |
} | |
$s = sprintf "%c", 64+$row; | |
$s =~ s/@/P/; | |
} | |
else { | |
warn "parse error in '$n'\n"; | |
} | |
$s .= $col; | |
return $s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment