<jupyter_start><jupyter_text>Calculate bi-radical weight in DNP Sample Preparation  Definitions<jupyter_code>import pandas as pd
import numpy as np
%config Completer.use_jedi = False 
import sys
from io import BytesIO
import requests as rq<jupyter_output><empty_output><jupyter_text>Read excel file for molecular weights<jupyter_code>url="https://raw.githubusercontent.com/dnp-grenoble/nmr_and_dnp_tools/main/mol_weight_radicals_dnp.csv"
#df = pd.read_csv('mol_weight_radicals_dnp.csv')
#print(df)
data = rq.get(url).content
df = pd.read_csv(BytesIO(data))
print(df)<jupyter_output>Name       MW
0             totapol   399.60
1              amupol   726.00
2              tekpol   905.00
3         asympol-pok   761.91
4        casympol-pok   842.04
5         asympol-tek   569.79
6        casympol-tek   649.92
7  pyrrhotripol-h-ome  1264.86
8      pyrrhotripol-h  1280.77<jupyter_text>Input biradical name, concentration in mM and volume in $\mu$l<jupyter_code>rad = input('Biradical: ')
conc = float(input('Concentration in mM: '))
volume = float(input('Volume in microlitres: '))

rad_name=df["Short"]
rad_weight=df["MW"]
w_idx = rad_name[rad_name.str.fullmatch(rad)].index

if w_idx.empty == True:
    sys.exit("Biradical not found, try to make it")
    
w_mg=conc*volume*rad_weight[w_idx]/1e6
print('The weight needed is ' + str(round(w_mg.iloc[0],2)) + ' mg')<jupyter_output>Biradical:  amu
Concentration in mM:  10
Volume in microlitres:  10
{'fraction_non_alphanumeric': 0.1096551724137931, 'fraction_numerical': 0.044137931034482755, 'mean_word_length': 4.073426573426573, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '148019', 'license': 'MIT', 'n_tokens_mistral': 602, 'n_tokens_neox': 552, 'n_words': 117, 'path': '.ipynb_checkpoints/calc_rad_weight-checkpoint.ipynb', 'repo_name': 'subhradip-paul/nmr_and_dnp_tools', 'size': '1450'}