Skip to content

Instantly share code, notes, and snippets.

@lmmx
Last active August 29, 2015 13:57
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 lmmx/9775329 to your computer and use it in GitHub Desktop.
Save lmmx/9775329 to your computer and use it in GitHub Desktop.

###Decimals from a string (of text)

To clean the data, use:
dataProcess(EthList,EthStarting,EthBest)
dataProcess(AmmList,AmmStarting,AmmBest), or
dataProcess(AffList,AffStarting,AffBest)

To open a console in the Chrome browser window use Ctrl + Shift + J (or + Opt + J on Mac).

The arrays of decimals produced can be copied as columns to the clipboard for pasting into a spreadsheet with:
copy(EthStarting.join("\n")),
copy(EthBest.join("\n")),
copy(AmmStarting.join("\n")),
copy(AmmBest.join("\n")),
copy(AffStarting.join("\n")), and
copy(AffBest.join("\n"))

NB: Click 'View Raw' above ( <> ) to copy the data below (or just get it from BlackBoard) as tabs are trimmed in markdown.

###Ethanol precipitation data:

21.91 40.71 1.679 0.307 7.2 7.0 6.8 0.85 21.855 36.17 14.6 6.19 1.53 1.73/10.05 0.639 0.864 6.03 1.21 5.508 140.8 66.97 0.74 9.45 33.675 9.42 33.957 7.18 34.1 39.7 142 7.58 8.03 7.66 34.04 3.617 2.76 5.3 5.72 26.7 51 19.52 26.5 10.85 41.65 7.45 21.16 0.297 0.14 11.3 9.22 29.16 61.21 7.67 2.66 5.6 117.9 40.6 0.067 9.5 13

###Ammonium sulphate precipitation/gel filtration data:

6.25 1.725 0.73 3.13 6.378 18.75 12.17 19.03 3.84 24.7 45.88 36 17.03 5.8 15.78 18.73 3.61 2.16 3.82 0.22 12.3 6.06 4.24 22.78 1.16 107.84 1.1 4.96 12.8 24.2 13.87 34.36 4.69 38.366 9.43 69.76 14.5 16.7 14.5 42.5 2.59 4.22 12.6 35 15.78 1.73 9.7 8.38 22.27 3.68 17.16 5.704 58 85 8.2 12.6 16.7 96.1

###Affinity purification data

0.981 5.83 0.291 0.556 0.57 4.1 0.43 92.4 0.22 256.6 0.69 226.5 0.02 9.44 2.55 38 2.4 32.4 2.087 0.428 1.869 3.822 0.22 74.75 0.612 255.55 0.94 56.25 0.212 10 0.3863 138 2.16 184.9 0.26 3.045 0.579 2.53 0.083 4.55 0.342 283 0.24 437.1 0.407 57.56 0.578 262.8 2.493 32.8 0.531 19.5 1.88 1.48 1.02 43.79 0.18 96.399 0.386 40.35 1.8 1.48 9.293 14.5 16.8 53.47 0.35 86.72 0.13 9.59 1.61 8.16 0.9 5.9 0.235 64.26 0.44 6.5 1.2 1.6 3.7 231.7 0.095 2.4

function dataProcess(list,start,best) {
lines = list.split("\n");
RegEx = /\d+[\/.]?\d+/g;
for (i=0; i<lines.length; i++) {
l = lines[i].split("\t");
start.push(parseFloat(l[0].match(RegEx).join("")));
best.push(parseFloat(l[l.length-1].match(RegEx).join("")));
}
}
var EthStarting = [];
var EthBest = [];
var AmmStarting = [];
var AmmBest = [];
var AffStarting = [];
var AffBest = [];
// Only run one of these at a time (a popup box will appear)
var EthList = prompt("Enter data"); // copy from instructions (or BlackBoard) and paste into the popup
dataProcess(EthList,EthStarting,EthBest)
var AmmList = prompt("Enter data");
dataProcess(AmmList,AmmStarting,AmmBest)
var AffList = prompt("Enter data");
dataProcess(AffList,AffStarting,AffBest)
// then copy the results (for horizontal rather than vertical change "\n" to "\t")
copy(EthStarting.join("\n"))
copy(EthBest.join("\n"))
copy(AmmStarting.join("\n"))
copy(AmmBest.join("\n"))
copy(AffStarting.join("\n"))
copy(AffBest.join("\n"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment