Skip to content

Instantly share code, notes, and snippets.

Created September 4, 2009 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/180628 to your computer and use it in GitHub Desktop.
Save anonymous/180628 to your computer and use it in GitHub Desktop.
# 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