{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Import Packages"},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\npd.set_option('display.max_colwidth', -1)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# InChI\n\nThe IUPAC International Chemical Identifier is a textual identifier for chemical substances, designed to provide a standard way to encode molecular information and to facilitate the search for such information in databases and on the web."},{"metadata":{},"cell_type":"markdown","source":"# Format and layers\n\n\nEvery InChI starts with the string \"InChI=\" followed by the version number, currently 1. If the InChI is standard, this is followed by the letter S for standard InChIs, which is a fully standardized InChI flavor maintaining the same level of attention to structure details and the same conventions for drawing perception. The remaining information is structured as a sequence of layers and sub-layers, with each layer providing one specific type of information. The layers and sub-layers are separated by the delimiter \"/\" and start with a characteristic prefix letter (except for the chemical formula sub-layer of the main layer). The six layers with important sublayers are:\n\n## Main layer\nChemical formula (no prefix). This is the only sublayer that must occur in every InChI.\nAtom connections (prefix: \"c\"). The atoms in the chemical formula (except for hydrogens) are numbered in sequence; this sublayer describes which atoms are connected by bonds to which other ones.\nHydrogen atoms (prefix: \"h\"). Describes how many hydrogen atoms are connected to each of the other atoms.\n\n## Charge layer\ncharge sublayer (prefix: \"q\")\nproton sublayer (prefix: \"p\" for \"protons\")\n\n## Stereochemical layer\ndouble bonds and cumulenes (prefix: \"b\")\ntetrahedral stereochemistry of atoms and allenes (prefixes: \"t\", \"m\")\ntype of stereochemistry information (prefix: \"s\")\n\n## Isotopic layer \n(prefixes: \"i\", \"h\", as well as \"b\", \"t\", \"m\", \"s\" for isotopic stereochemistry)\n\n## Fixed-H layer\n(prefix: \"f\"); contains some or all of the above types of layers except atom connections; may end with \"o\" sublayer; never included in standard InChI\n\n## Reconnected layer \n(prefix: \"r\"); contains the whole InChI of a structure with reconnected metal atoms; never included in standard InChI"},{"metadata":{},"cell_type":"markdown","source":"# Training Data\n\ntrain_labels - This gives the ground truth InChi labels for the training images"},{"metadata":{"trusted":true},"cell_type":"code","source":"import os\nos.listdir('/kaggle/input/bms-molecular-translation/')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df = pd.read_csv('/kaggle/input/bms-molecular-translation/train_labels.csv')\nprint(train_df.shape)\ntrain_df","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df['split'] = train_df['InChI'].apply(lambda x: x.split('/'))\ntrain_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df['split_len'] = train_df['split'].apply(lambda x: len(x))\ntrain_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df['split_len'].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df = train_df['InChI'].str.split('/', 11, expand=True)\ntrain_InChI_df","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[0].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[1].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[2].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[3].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[4].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[5].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[6].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[7].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[8].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[9].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_InChI_df[10].unique()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}