{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chemical Structure Inputs for PUGREST" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "S. Kim, J. Cuadros\n", "August 21st, 2019" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Objectives" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use SMILES and InChI strings to specify the input compound for a PUG-REST request.\n", "Use a structure-data (SD) file to specify the input compound for a PUG-REST request.\n", "Learn to submit a PUG-REST request using the HTTP-POST method." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Background" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can use a chemical structure as an input for a PUG-REST request. PUG-REST accepts some popular\n", "chemical structure line notations such as SMILES and InChI strings. It is also possible to use an StructureData File (SDF) as a structure input." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To learn how to specify the structure input in a PUG-REST request, one needs to know that there are two\n", "methods by which data are transferred from clients (users) and servers (PubChem) through PUG-REST.\n", "Discussing what these methods are in detail is beyond the scope of this material, and it is enough to know\n", "three things:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- When you make a PUG-REST request by typing the request URL in the address bar of your web browser (such as Google Chrome, MS Internet Explorer), the HTTP GET method is used\n", "- The HTTP GET method transfers information encoded in a single-line URL.\n", "- Some chemical structure inputs are not appropriate to encode in a single-line URL (because they may contain special characters not compatible with the URL syntax, span over multiple lines, or too long),and the HTTP POST needs to be used for such cases.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For more information on HTTP GET and POST, read the following documents." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- HTTP request methods (https://www.w3schools.com/tags/ref_httpmethods.asp)\n", "- GET vs. POST (https://www.diffen.com/difference/GET-vs-POST-HTTP-Requests)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will be using the httr package." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "(The require function checks whether a package has already been installed and loads it if so. It returns a logical value than can be used to install the package if it was not available.)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# When running in Rstudio, you may need to install httr\n", "#if(!require(\"httr\", quietly=TRUE)) {\n", "# install.packages(\"httr\", repos=\"https://cloud.r-project.org/\",\n", "# quiet=TRUE, type=\"binary\")\n", "\n", "library(\"httr\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Packages are the way that libraries (additional functions, data types, constants, data sets…) are distributed in the R environment. In order to use a package, it has to be installed (only once per running environment) with the install.packages function. Then, if we load it (in a specific R session) using library , its functions can be called as they were in the base environment." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The httr package allows a finer grade manipulation of the HTTP communications. That’s why we will use it in this activity. A quick introduction to the package is available at https://cran.rproject.org/web/packages/httr/vignettes/quickstart.html " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 1. Using the HTTP GET method." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.1. Structure encoded in the URL path." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In some cases, you can encode a chemical structure in the PUG-REST request URL path as in the following example" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CC(C)CC1=CC=C(C=C1)C(C)C(=O)O/cids/txt'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CC(C)CC1=CC=C(C=C1)C(C)C(=O)O/cids/txt'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CC(C)CC1=CC=C(C=C1)C(C)C(=O)O/cids/txt'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CC(C)CC1=CC=C(C=C1)C(C)C(=O)O/cids/txt\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "prolog <- 'https://pubchem.ncbi.nlm.nih.gov/rest/pug'\n", "smiles1 <- \"CC(C)CC1=CC=C(C=C1)C(C)C(=O)O\" \n", "url <- paste(prolog, \"/compound/smiles/\", smiles1, \"/cids/txt\", sep=\"\") \n", "url" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'3672\\n'" ], "text/latex": [ "'3672\\textbackslash{}n'" ], "text/markdown": [ "'3672\\n'" ], "text/plain": [ "[1] \"3672\\n\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "res = GET(url) \n", "content(res,\"text\",encoding=\"UTF-8\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It should be noteworthy that some SMILES strings contain special characters, such as the forward slash (“/”),\n", "which is also used in the URL path. These special characters conflict with the PUG-REST request URL syntax,\n", "causing an error when used in the PUG-REST request URL.\n", "\n", "Also note that the backslash character has to be escaped when used in a string in R. To include a blackslash, we have to write \\\\ ." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O/cids/txt'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CC1=C({[}C@@{]}(SC1=O)(C)/C=C(\\textbackslash{}\\textbackslash{}C)/C=C)O/cids/txt'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O/cids/txt'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O/cids/txt\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "smiles2 <- \"CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O\"\n", "url <- paste(prolog, \"/compound/smiles/\", smiles2, \"/cids/txt\", sep=\"\")\n", "url" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'Status: 400\\nCode: PUGREST.BadRequest\\nMessage: Unable to standardize the given structure - perhaps some special characters need to be escaped or data packed in a MIME form?\\nDetail: error: \\nDetail: status: 400\\nDetail: output: Caught ncbi::CException: Standardization failed\\nDetail: Output Log:\\nDetail: Record 1: Warning: Cactvs Ensemble cannot be created from input string\\nDetail: Record 1: Error: Unable to convert input into a compound object\\nDetail: \\nDetail: \\n'" ], "text/latex": [ "'Status: 400\\textbackslash{}nCode: PUGREST.BadRequest\\textbackslash{}nMessage: Unable to standardize the given structure - perhaps some special characters need to be escaped or data packed in a MIME form?\\textbackslash{}nDetail: error: \\textbackslash{}nDetail: status: 400\\textbackslash{}nDetail: output: Caught ncbi::CException: Standardization failed\\textbackslash{}nDetail: Output Log:\\textbackslash{}nDetail: Record 1: Warning: Cactvs Ensemble cannot be created from input string\\textbackslash{}nDetail: Record 1: Error: Unable to convert input into a compound object\\textbackslash{}nDetail: \\textbackslash{}nDetail: \\textbackslash{}n'" ], "text/markdown": [ "'Status: 400\\nCode: PUGREST.BadRequest\\nMessage: Unable to standardize the given structure - perhaps some special characters need to be escaped or data packed in a MIME form?\\nDetail: error: \\nDetail: status: 400\\nDetail: output: Caught ncbi::CException: Standardization failed\\nDetail: Output Log:\\nDetail: Record 1: Warning: Cactvs Ensemble cannot be created from input string\\nDetail: Record 1: Error: Unable to convert input into a compound object\\nDetail: \\nDetail: \\n'" ], "text/plain": [ "[1] \"Status: 400\\nCode: PUGREST.BadRequest\\nMessage: Unable to standardize the given structure - perhaps some special characters need to be escaped or data packed in a MIME form?\\nDetail: error: \\nDetail: status: 400\\nDetail: output: Caught ncbi::CException: Standardization failed\\nDetail: Output Log:\\nDetail: Record 1: Warning: Cactvs Ensemble cannot be created from input string\\nDetail: Record 1: Error: Unable to convert input into a compound object\\nDetail: \\nDetail: \\n\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "res <- GET(url)\n", "content(res,\"text\",encoding=\"UTF-8\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.2. Structure encoded as a URL argument\n", "\n", "To circumvent the issue mentioned above, the SMILES string may be encoded as the URL argments (as an optional parameter followed by the “?” character).\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1=C({[}C@@{]}(SC1=O)(C)/C=C(\\textbackslash{}\\textbackslash{}C)/C=C)O'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "url2 <- paste(prolog, \"/compound/smiles/cids/txt?smiles=\", smiles2, sep=\"\")\n", "url2" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'135403829\\n'" ], "text/latex": [ "'135403829\\textbackslash{}n'" ], "text/markdown": [ "'135403829\\n'" ], "text/plain": [ "[1] \"135403829\\n\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "res2 <- GET(url2)\n", "content(res2,\"text\",encoding=\"UTF-8\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.3. Structure encoded as a URL-encoded URL argument" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "It is also possible to pass the structure query as a URL-encoded argument. The following example does the\n", "same task as the previous example does.\n", "This is safer in case the argument includes & , ? or other reserved characters." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1%3DC%28%5BC%40%40%5D%28SC1%3DO%29%28C%29%2FC%3DC%28%5CC%29%2FC%3DC%29O'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1\\%3DC\\%28\\%5BC\\%40\\%40\\%5D\\%28SC1\\%3DO\\%29\\%28C\\%29\\%2FC\\%3DC\\%28\\%5CC\\%29\\%2FC\\%3DC\\%29O'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1%3DC%28%5BC%40%40%5D%28SC1%3DO%29%28C%29%2FC%3DC%28%5CC%29%2FC%3DC%29O'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1%3DC%28%5BC%40%40%5D%28SC1%3DO%29%28C%29%2FC%3DC%28%5CC%29%2FC%3DC%29O\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "url3 <- paste(prolog, \"/compound/smiles/cids/txt?smiles=\", URLencode(smiles2,reserved=TRUE), sep=\"\")\n", "url3" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'135403829\\n'" ], "text/latex": [ "'135403829\\textbackslash{}n'" ], "text/markdown": [ "'135403829\\n'" ], "text/plain": [ "[1] \"135403829\\n\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "res3 <- GET(url3)\n", "content(res3,\"text\",encoding=\"UTF-8\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The object returned from a web service request (res, res2, and res3 in our examples) contains information on\n", "the request URL through which the data have been retrieved. This information can be accessed using the\n", "$url attribute of the object, as shown in this example:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1=C({[}C@@{]}(SC1=O)(C)/C=C(\\textbackslash{}\\textbackslash{}C)/C=C)O'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1=C([C@@](SC1=O)(C)/C=C(\\\\C)/C=C)O\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "res2$url # from (2) structure encoded as a URL argument" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1%3DC%28%5BC%40%40%5D%28SC1%3DO%29%28C%29%2FC%3DC%28%5CC%29%2FC%3DC%29O'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1\\%3DC\\%28\\%5BC\\%40\\%40\\%5D\\%28SC1\\%3DO\\%29\\%28C\\%29\\%2FC\\%3DC\\%28\\%5CC\\%29\\%2FC\\%3DC\\%29O'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1%3DC%28%5BC%40%40%5D%28SC1%3DO%29%28C%29%2FC%3DC%28%5CC%29%2FC%3DC%29O'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt?smiles=CC1%3DC%28%5BC%40%40%5D%28SC1%3DO%29%28C%29%2FC%3DC%28%5CC%29%2FC%3DC%29O\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "res3$url # from (3) structure encoded as a URL-encoded URL argument" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that URL-encoding does not work for PubChem when including structure information in the URL path.\n", "\n", "**Exercise 1a:** Retrieve the hydrogen bond donor, acceptor counts, TPSA, and XLogP of the chemical represented by the SMILES string: 1=CC(=C(C=C1Cl)O)OC2=C(C=C(C=C2)Cl)Cl”. \n", "\n", "Then construct a PUGREST url for this request, encode the structure in the URL path." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Type your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 1b:** Get the CID corresponding to the following InChI string, using the HTTP GET method" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "inchi <- \"InChI=1S/C17H14O4S/c1-22(19,20)14-9-7-12(8-10-14)15-11-21-17(18)16(15)13-5-3-2-4-6-\n", "13/h2-10H,11H2,1H3\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2. Using the HTTP POST method" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2.1. Comparison of HTTP POST and GET" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All the three examples above use the HTTP GET method, as implied in the use of the GET function.\n", "Alternatively, one can use the HTTP POST method. For example, the following example returns the identical\n", "result as the last two HTTP GET examples" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "url <- paste(prolog, \"/compound/smiles/cids/txt\", sep=\"\")\n", "struct <- list(smiles=smiles2)\n", "res <- POST(url, body = struct)\n", "res$url" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'135403829\\n'" ], "text/latex": [ "'135403829\\textbackslash{}n'" ], "text/markdown": [ "'135403829\\n'" ], "text/plain": [ "[1] \"135403829\\n\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "content(res,\"text\",encoding=\"UTF-8\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When using the HTTP POST method, information is passed as data through the body argument. Because of\n", "this, the URL stored in the res$url does not contain structure informaion." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2.2. HTTP POST for multi-line structure input" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2.1. Comparison of HTTP POST and GET" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "All the three examples above use the HTTP GET method, as implied in the use of the GET function.\n", "Alternatively, one can use the HTTP POST method. For example, the following example returns the identical\n", "result as the last two HTTP GET examples." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "url <- paste(prolog, \"/compound/smiles/cids/txt\", sep=\"\")\n", "struct <- list(smiles = smiles2)\n", "\n", "res <- POST(url, body = struct)\n", "res$url" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'135403829\\n'" ], "text/latex": [ "'135403829\\textbackslash{}n'" ], "text/markdown": [ "'135403829\\n'" ], "text/plain": [ "[1] \"135403829\\n\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "content(res,\"text\",encoding=\"UTF-8\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When using the HTTP POST method, information is passed as data through the body argument. Because of\n", "this, the URL stored in the res$url does not contain structure information." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2.2. HTTP POST for multi-line structure input" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The HTTP POST method should be used if the input molecular structure for PUG-REST request span over\n", "multiple lines (e.g., stored in a structure-data file (SDF) format). The SDF file contains structure information of\n", "a molecule in a multi-line format, along with other data." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "mysdf <-\"1983\n", " -OEChem-07241917072D\n", "\n", " 20 20 0 0 0 0 0 0 0999 V2000\n", " 2.8660 -2.5950 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n", " 4.5981 1.4050 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.8660 1.4050 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.8660 0.4050 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.7320 -0.0950 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.0000 -0.0950 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.7320 -1.0950 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.0000 -1.0950 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.8660 -1.5950 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.7320 1.9050 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.7320 2.9050 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 4.2690 0.2150 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 1.4631 0.2150 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.3291 1.7150 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 4.2690 -1.4050 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 1.4631 -1.4050 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 4.3520 2.9050 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.7320 3.5250 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.1120 2.9050 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.3291 -2.9050 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 1 9 1 0 0 0 0\n", " 1 20 1 0 0 0 0\n", " 2 10 2 0 0 0 0\n", " 3 4 1 0 0 0 0\n", " 3 10 1 0 0 0 0\n", " 3 14 1 0 0 0 0\n", " 4 5 2 0 0 0 0\n", " 4 6 1 0 0 0 0\n", " 5 7 1 0 0 0 0\n", " 5 12 1 0 0 0 0\n", " 6 8 2 0 0 0 0\n", " 6 13 1 0 0 0 0\n", " 7 9 2 0 0 0 0\n", " 7 15 1 0 0 0 0\n", " 8 9 1 0 0 0 0\n", " 8 16 1 0 0 0 0\n", " 10 11 1 0 0 0 0\n", " 11 17 1 0 0 0 0\n", " 11 18 1 0 0 0 0\n", " 11 19 1 0 0 0 0\n", "M END\n", "> \n", "1983\n", "\n", "> \n", "1\n", "\n", "> \n", "139\n", "\n", "> \n", "2\n", "\n", "> \n", "2\n", "\n", "> \n", "1\n", "$$$$\n", "\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Multi-line string in R can be written without any special consideration. This multi-line sdf data is used as an\n", "input for a PUG-REST request through the HTTP POST." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/cids/txt'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/cids/txt'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/cids/txt'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/cids/txt\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "url <- paste(prolog, \"/compound/sdf/cids/txt\", sep=\"\")\n", "mydata <- list(sdf=mysdf)\n", "res <- POST(url, body = mydata)\n", "res$url" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'1983\\n'" ], "text/latex": [ "'1983\\textbackslash{}n'" ], "text/markdown": [ "'1983\\n'" ], "text/plain": [ "[1] \"1983\\n\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "content(res,\"text\",encoding=\"UTF-8\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that HTTP POST should be used for the input specification using a SDF format. Although HTTP GET\n", "may work if data is URL-encoded, it will be more dependent of URL length limitations." ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/cids/txt?sdf=1983%0A%20%20-OEChem-07241917072D%0A%0A%2020%2020%20%200%20%20%20%20%200%20%200%20%200%20%200%20%200%20%200999%20V2000%0A%20%20%20%202.8660%20%20%20-2.5950%20%20%20%200.0000%20O%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.5981%20%20%20%201.4050%20%20%20%200.0000%20O%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20%201.4050%20%20%20%200.0000%20N%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20%200.4050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20-0.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.0000%20%20%20-0.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20-1.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.0000%20%20%20-1.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20-1.5950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%201.9050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%202.9050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.2690%20%20%20%200.2150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%201.4631%20%20%20%200.2150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.3291%20%20%20%201.7150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.2690%20%20%20-1.4050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%201.4631%20%20%20-1.4050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.3520%20%20%20%202.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%203.5250%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.1120%20%20%20%202.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.3291%20%20%20-2.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%201%20%209%20%201%20%200%20%200%20%200%20%200%0A%20%201%2020%20%201%20%200%20%200%20%200%20%200%0A%20%202%2010%20%202%20%200%20%200%20%200%20%200%0A%20%203%20%204%20%201%20%200%20%200%20%200%20%200%0A%20%203%2010%20%201%20%200%20%200%20%200%20%200%0A%20%203%2014%20%201%20%200%20%200%20%200%20%200%0A%20%204%20%205%20%202%20%200%20%200%20%200%20%200%0A%20%204%20%206%20%201%20%200%20%200%20%200%20%200%0A%20%205%20%207%20%201%20%200%20%200%20%200%20%200%0A%20%205%2012%20%201%20%200%20%200%20%200%20%200%0A%20%206%20%208%20%202%20%200%20%200%20%200%20%200%0A%20%206%2013%20%201%20%200%20%200%20%200%20%200%0A%20%207%20%209%20%202%20%200%20%200%20%200%20%200%0A%20%207%2015%20%201%20%200%20%200%20%200%20%200%0A%20%208%20%209%20%201%20%200%20%200%20%200%20%200%0A%20%208%2016%20%201%20%200%20%200%20%200%20%200%0A%2010%2011%20%201%20%200%20%200%20%200%20%200%0A%2011%2017%20%201%20%200%20%200%20%200%20%200%0A%2011%2018%20%201%20%200%20%200%20%200%20%200%0A%2011%2019%20%201%20%200%20%200%20%200%20%200%0AM%20%20END%0A%3E%20%3CPUBCHEM_COMPOUND_CID%3E%0A1983%0A%0A%3E%20%3CPUBCHEM_COMPOUND_CANONICALIZED%3E%0A1%0A%0A%3E%20%3CPUBCHEM_CACTVS_COMPLEXITY%3E%0A139%0A%0A%3E%20%3CPUBCHEM_CACTVS_HBOND_ACCEPTOR%3E%0A2%0A%0A%3E%20%3CPUBCHEM_CACTVS_HBOND_DONOR%3E%0A2%0A%0A%3E%20%3CPUBCHEM_CACTVS_ROTATABLE_BOND%3E%0A1%0A%24%24%24%24%0A'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/cids/txt?sdf=1983\\%0A\\%20\\%20-OEChem-07241917072D\\%0A\\%0A\\%2020\\%2020\\%20\\%200\\%20\\%20\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200999\\%20V2000\\%0A\\%20\\%20\\%20\\%202.8660\\%20\\%20\\%20-2.5950\\%20\\%20\\%20\\%200.0000\\%20O\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%204.5981\\%20\\%20\\%20\\%201.4050\\%20\\%20\\%20\\%200.0000\\%20O\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%202.8660\\%20\\%20\\%20\\%201.4050\\%20\\%20\\%20\\%200.0000\\%20N\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%202.8660\\%20\\%20\\%20\\%200.4050\\%20\\%20\\%20\\%200.0000\\%20C\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%203.7320\\%20\\%20\\%20-0.0950\\%20\\%20\\%20\\%200.0000\\%20C\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%202.0000\\%20\\%20\\%20-0.0950\\%20\\%20\\%20\\%200.0000\\%20C\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%203.7320\\%20\\%20\\%20-1.0950\\%20\\%20\\%20\\%200.0000\\%20C\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%202.0000\\%20\\%20\\%20-1.0950\\%20\\%20\\%20\\%200.0000\\%20C\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%202.8660\\%20\\%20\\%20-1.5950\\%20\\%20\\%20\\%200.0000\\%20C\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%203.7320\\%20\\%20\\%20\\%201.9050\\%20\\%20\\%20\\%200.0000\\%20C\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%203.7320\\%20\\%20\\%20\\%202.9050\\%20\\%20\\%20\\%200.0000\\%20C\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%204.2690\\%20\\%20\\%20\\%200.2150\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%201.4631\\%20\\%20\\%20\\%200.2150\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%202.3291\\%20\\%20\\%20\\%201.7150\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%204.2690\\%20\\%20\\%20-1.4050\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%201.4631\\%20\\%20\\%20-1.4050\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%204.3520\\%20\\%20\\%20\\%202.9050\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%203.7320\\%20\\%20\\%20\\%203.5250\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%203.1120\\%20\\%20\\%20\\%202.9050\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%20\\%20\\%202.3291\\%20\\%20\\%20-2.9050\\%20\\%20\\%20\\%200.0000\\%20H\\%20\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%201\\%20\\%209\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%201\\%2020\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%202\\%2010\\%20\\%202\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%203\\%20\\%204\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%203\\%2010\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%203\\%2014\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%204\\%20\\%205\\%20\\%202\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%204\\%20\\%206\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%205\\%20\\%207\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%205\\%2012\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%206\\%20\\%208\\%20\\%202\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%206\\%2013\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%207\\%20\\%209\\%20\\%202\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%207\\%2015\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%208\\%20\\%209\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%20\\%208\\%2016\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%2010\\%2011\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%2011\\%2017\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%2011\\%2018\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0A\\%2011\\%2019\\%20\\%201\\%20\\%200\\%20\\%200\\%20\\%200\\%20\\%200\\%0AM\\%20\\%20END\\%0A\\%3E\\%20\\%3CPUBCHEM\\_COMPOUND\\_CID\\%3E\\%0A1983\\%0A\\%0A\\%3E\\%20\\%3CPUBCHEM\\_COMPOUND\\_CANONICALIZED\\%3E\\%0A1\\%0A\\%0A\\%3E\\%20\\%3CPUBCHEM\\_CACTVS\\_COMPLEXITY\\%3E\\%0A139\\%0A\\%0A\\%3E\\%20\\%3CPUBCHEM\\_CACTVS\\_HBOND\\_ACCEPTOR\\%3E\\%0A2\\%0A\\%0A\\%3E\\%20\\%3CPUBCHEM\\_CACTVS\\_HBOND\\_DONOR\\%3E\\%0A2\\%0A\\%0A\\%3E\\%20\\%3CPUBCHEM\\_CACTVS\\_ROTATABLE\\_BOND\\%3E\\%0A1\\%0A\\%24\\%24\\%24\\%24\\%0A'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/cids/txt?sdf=1983%0A%20%20-OEChem-07241917072D%0A%0A%2020%2020%20%200%20%20%20%20%200%20%200%20%200%20%200%20%200%20%200999%20V2000%0A%20%20%20%202.8660%20%20%20-2.5950%20%20%20%200.0000%20O%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.5981%20%20%20%201.4050%20%20%20%200.0000%20O%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20%201.4050%20%20%20%200.0000%20N%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20%200.4050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20-0.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.0000%20%20%20-0.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20-1.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.0000%20%20%20-1.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20-1.5950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%201.9050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%202.9050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.2690%20%20%20%200.2150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%201.4631%20%20%20%200.2150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.3291%20%20%20%201.7150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.2690%20%20%20-1.4050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%201.4631%20%20%20-1.4050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.3520%20%20%20%202.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%203.5250%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.1120%20%20%20%202.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.3291%20%20%20-2.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%201%20%209%20%201%20%200%20%200%20%200%20%200%0A%20%201%2020%20%201%20%200%20%200%20%200%20%200%0A%20%202%2010%20%202%20%200%20%200%20%200%20%200%0A%20%203%20%204%20%201%20%200%20%200%20%200%20%200%0A%20%203%2010%20%201%20%200%20%200%20%200%20%200%0A%20%203%2014%20%201%20%200%20%200%20%200%20%200%0A%20%204%20%205%20%202%20%200%20%200%20%200%20%200%0A%20%204%20%206%20%201%20%200%20%200%20%200%20%200%0A%20%205%20%207%20%201%20%200%20%200%20%200%20%200%0A%20%205%2012%20%201%20%200%20%200%20%200%20%200%0A%20%206%20%208%20%202%20%200%20%200%20%200%20%200%0A%20%206%2013%20%201%20%200%20%200%20%200%20%200%0A%20%207%20%209%20%202%20%200%20%200%20%200%20%200%0A%20%207%2015%20%201%20%200%20%200%20%200%20%200%0A%20%208%20%209%20%201%20%200%20%200%20%200%20%200%0A%20%208%2016%20%201%20%200%20%200%20%200%20%200%0A%2010%2011%20%201%20%200%20%200%20%200%20%200%0A%2011%2017%20%201%20%200%20%200%20%200%20%200%0A%2011%2018%20%201%20%200%20%200%20%200%20%200%0A%2011%2019%20%201%20%200%20%200%20%200%20%200%0AM%20%20END%0A%3E%20%3CPUBCHEM_COMPOUND_CID%3E%0A1983%0A%0A%3E%20%3CPUBCHEM_COMPOUND_CANONICALIZED%3E%0A1%0A%0A%3E%20%3CPUBCHEM_CACTVS_COMPLEXITY%3E%0A139%0A%0A%3E%20%3CPUBCHEM_CACTVS_HBOND_ACCEPTOR%3E%0A2%0A%0A%3E%20%3CPUBCHEM_CACTVS_HBOND_DONOR%3E%0A2%0A%0A%3E%20%3CPUBCHEM_CACTVS_ROTATABLE_BOND%3E%0A1%0A%24%24%24%24%0A'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/cids/txt?sdf=1983%0A%20%20-OEChem-07241917072D%0A%0A%2020%2020%20%200%20%20%20%20%200%20%200%20%200%20%200%20%200%20%200999%20V2000%0A%20%20%20%202.8660%20%20%20-2.5950%20%20%20%200.0000%20O%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.5981%20%20%20%201.4050%20%20%20%200.0000%20O%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20%201.4050%20%20%20%200.0000%20N%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20%200.4050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20-0.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.0000%20%20%20-0.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20-1.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.0000%20%20%20-1.0950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.8660%20%20%20-1.5950%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%201.9050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%202.9050%20%20%20%200.0000%20C%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.2690%20%20%20%200.2150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%201.4631%20%20%20%200.2150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.3291%20%20%20%201.7150%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.2690%20%20%20-1.4050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%201.4631%20%20%20-1.4050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%204.3520%20%20%20%202.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.7320%20%20%20%203.5250%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%203.1120%20%20%20%202.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%20%20%202.3291%20%20%20-2.9050%20%20%20%200.0000%20H%20%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%20%200%0A%20%201%20%209%20%201%20%200%20%200%20%200%20%200%0A%20%201%2020%20%201%20%200%20%200%20%200%20%200%0A%20%202%2010%20%202%20%200%20%200%20%200%20%200%0A%20%203%20%204%20%201%20%200%20%200%20%200%20%200%0A%20%203%2010%20%201%20%200%20%200%20%200%20%200%0A%20%203%2014%20%201%20%200%20%200%20%200%20%200%0A%20%204%20%205%20%202%20%200%20%200%20%200%20%200%0A%20%204%20%206%20%201%20%200%20%200%20%200%20%200%0A%20%205%20%207%20%201%20%200%20%200%20%200%20%200%0A%20%205%2012%20%201%20%200%20%200%20%200%20%200%0A%20%206%20%208%20%202%20%200%20%200%20%200%20%200%0A%20%206%2013%20%201%20%200%20%200%20%200%20%200%0A%20%207%20%209%20%202%20%200%20%200%20%200%20%200%0A%20%207%2015%20%201%20%200%20%200%20%200%20%200%0A%20%208%20%209%20%201%20%200%20%200%20%200%20%200%0A%20%208%2016%20%201%20%200%20%200%20%200%20%200%0A%2010%2011%20%201%20%200%20%200%20%200%20%200%0A%2011%2017%20%201%20%200%20%200%20%200%20%200%0A%2011%2018%20%201%20%200%20%200%20%200%20%200%0A%2011%2019%20%201%20%200%20%200%20%200%20%200%0AM%20%20END%0A%3E%20%3CPUBCHEM_COMPOUND_CID%3E%0A1983%0A%0A%3E%20%3CPUBCHEM_COMPOUND_CANONICALIZED%3E%0A1%0A%0A%3E%20%3CPUBCHEM_CACTVS_COMPLEXITY%3E%0A139%0A%0A%3E%20%3CPUBCHEM_CACTVS_HBOND_ACCEPTOR%3E%0A2%0A%0A%3E%20%3CPUBCHEM_CACTVS_HBOND_DONOR%3E%0A2%0A%0A%3E%20%3CPUBCHEM_CACTVS_ROTATABLE_BOND%3E%0A1%0A%24%24%24%24%0A\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "url3 <- paste(prolog, \"/compound/sdf/cids/txt?sdf=\",URLencode(mysdf,reserved=TRUE), sep=\"\")\n", "url3" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'1983\\n'" ], "text/latex": [ "'1983\\textbackslash{}n'" ], "text/markdown": [ "'1983\\n'" ], "text/plain": [ "[1] \"1983\\n\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "res3 <- GET(url3)\n", "content(res3,\"text\",encoding=\"UTF-8\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 2.3. HTTP POST for multi-line structure input" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One may want to use the structure stored in a file as the input for a PUG-REST request. The following code\n", "shows how to read an SDF file into a variable." ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5288826\n", " -OEChem-08171913162D\n", "\n", " 40 44 0 1 0 0 0 0 0999 V2000\n", " 2.2314 0.0528 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.0000 -2.4021 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.0000 2.4021 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n", " 6.1607 -0.9511 0.0000 N 0 0 3 0 0 0 0 0 0 0 0 0\n", " 3.6897 -0.4755 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0\n", " 4.5133 -0.9511 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0\n", " 5.3370 -0.4755 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0\n", " 2.8660 -0.9511 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0\n", " 4.2392 0.2219 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.6897 0.4755 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.3370 0.4755 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.5918 0.2219 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 4.5133 0.9511 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.8660 -1.9022 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0\n", " 4.5133 -1.9022 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.8660 0.9511 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.6897 -2.3777 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 6.8418 -1.6832 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 4.5133 1.9022 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.8660 1.9022 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.6897 2.3777 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.0597 -1.6022 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.6284 -1.2740 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.0496 -1.1875 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 4.3760 0.8266 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.6795 0.4887 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.9476 0.3679 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.5490 1.0581 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 6.1840 0.4057 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.4989 0.8349 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.8660 -2.5222 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.0503 -2.2122 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.6897 -2.9977 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 6.3879 -2.1055 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 7.2641 -2.1371 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 7.2957 -1.2609 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 5.0503 2.2122 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 3.6897 2.9977 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.0000 -3.0222 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 2.0000 3.0222 0.0000 H 0 0 0 0 0 0 0 0 0 0 0 0\n", " 1 8 1 0 0 0 0\n", " 1 16 1 0 0 0 0\n", " 14 2 1 6 0 0 0\n", " 2 39 1 0 0 0 0\n", " 3 20 1 0 0 0 0\n", " 3 40 1 0 0 0 0\n", " 4 7 1 0 0 0 0\n", " 4 12 1 0 0 0 0\n", " 4 18 1 0 0 0 0\n", " 5 6 1 0 0 0 0\n", " 5 8 1 0 0 0 0\n", " 5 9 1 1 0 0 0\n", " 5 10 1 0 0 0 0\n", " 6 7 1 0 0 0 0\n", " 6 15 1 0 0 0 0\n", " 6 22 1 1 0 0 0\n", " 7 11 1 0 0 0 0\n", " 7 23 1 6 0 0 0\n", " 8 14 1 0 0 0 0\n", " 8 24 1 1 0 0 0\n", " 9 12 1 0 0 0 0\n", " 9 25 1 0 0 0 0\n", " 9 26 1 0 0 0 0\n", " 10 13 2 0 0 0 0\n", " 10 16 1 0 0 0 0\n", " 11 13 1 0 0 0 0\n", " 11 27 1 0 0 0 0\n", " 11 28 1 0 0 0 0\n", " 12 29 1 0 0 0 0\n", " 12 30 1 0 0 0 0\n", " 13 19 1 0 0 0 0\n", " 14 17 1 0 0 0 0\n", " 14 31 1 0 0 0 0\n", " 15 17 2 0 0 0 0\n", " 15 32 1 0 0 0 0\n", " 16 20 2 0 0 0 0\n", " 17 33 1 0 0 0 0\n", " 18 34 1 0 0 0 0\n", " 18 35 1 0 0 0 0\n", " 18 36 1 0 0 0 0\n", " 19 21 2 0 0 0 0\n", " 19 37 1 0 0 0 0\n", " 20 21 1 0 0 0 0\n", " 21 38 1 0 0 0 0\n", "M END\n", "> \n", "5288826\n", "\n", "> \n", "1\n", "\n", "> \n", "494\n", "\n", "> \n", "4\n", "\n", "> \n", "2\n", "\n", "> \n", "0\n", "\n", "> \n", "AAADceB6MAAAAAAAAAAAAAAAAAAAASAAAAA8YIEAAAAWAEjBAAAAHgAACAAADzzhmAYyBoMABgCAAiBCAAACCAAgIAAIiAAOiIgNNiKGsRuGeCOkwBGLuAew8PcPoAABAAAYQADQAAaAADSAAAAAAAAAAA==\n", "\n", "> \n", "(4R,4aR,7S,7aR,12bS)-3-methyl-2,4,4a,7,7a,13-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol\n", "\n", "> \n", "(4R,4aR,7S,7aR,12bS)-3-methyl-2,4,4a,7,7a,13-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol\n", "\n", "> \n", "(4R,4aR,7S,7aR,12bS)-3-methyl-2,4,4a,7,7a,13-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol\n", "\n", "> \n", "(4R,4aR,7S,7aR,12bS)-3-methyl-2,4,4a,7,7a,13-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol\n", "\n", "> \n", "(4R,4aR,7S,7aR,12bS)-3-methyl-2,4,4a,7,7a,13-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol\n", "\n", "> \n", "(4R,4aR,7S,7aR,12bS)-3-methyl-2,4,4a,7,7a,13-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol\n", "\n", "> \n", "InChI=1S/C17H19NO3/c1-18-7-6-17-10-3-5-13(20)16(17)21-15-12(19)4-2-9(14(15)17)8-11(10)18/h2-5,10-11,13,16,19-20H,6-8H2,1H3/t10-,11+,13-,16-,17-/m0/s1\n", "\n", "> \n", "BQJCRHHNABKAKU-KBQPJGBKSA-N\n", "\n", "> \n", "0.8\n", "\n", "> \n", "285.136493\n", "\n", "> \n", "C17H19NO3\n", "\n", "> \n", "285.34\n", "\n", "> \n", "CN1CCC23C4C1CC5=C2C(=C(C=C5)O)OC3C(C=C4)O\n", "\n", "> \n", "CN1CC[C@]23[C@@H]4[C@H]1CC5=C2C(=C(C=C5)O)O[C@H]3[C@H](C=C4)O\n", "\n", "> \n", "52.9\n", "\n", "> \n", "285.136493\n", "\n", "> \n", "0\n", "\n", "> \n", "21\n", "\n", "> \n", "5\n", "\n", "> \n", "0\n", "\n", "> \n", "0\n", "\n", "> \n", "0\n", "\n", "> \n", "0\n", "\n", "> \n", "1\n", "\n", "> \n", "-1\n", "\n", "> \n", "1\n", "5\n", "255\n", "\n", "> \n", "10 13 8\n", "10 16 8\n", "13 19 8\n", "16 20 8\n", "19 21 8\n", "14 2 6\n", "20 21 8\n", "5 9 5\n", "6 22 5\n", "7 23 6\n", "8 24 5\n", "\n", "$$$$" ] } ], "source": [ "mysdf <- paste(readLines('Structure2D_CID_5288826.sdf'),collapse=\"\\n\")\n", "cat(mysdf)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "cat is used in this example instead of print (which can be omitted) as it produces a nicer print-out for\n", "multiple-line strings.\n", "\n", "Now the structure stored in the “mysdf” can be used in a PUG-REST request through HTTP-POST. For\n", "example, the code cell below shows how to retrieve various names (also called “synonyms”) of the input\n", "structure." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/synonyms/txt'" ], "text/latex": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/synonyms/txt'" ], "text/markdown": [ "'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/synonyms/txt'" ], "text/plain": [ "[1] \"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/sdf/synonyms/txt\"" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "url <- paste(prolog, \"/compound/sdf/synonyms/txt\", sep=\"\")\n", "mydata <- list(sdf=mysdf)\n", "\n", "res <- POST(url, body = mydata)\n", "res$url" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "morphine\n", "Morphia\n", "Morphinum\n", "Morphium\n", "Morphina\n", "Morphin\n", "(-)-Morphine\n", "Duromorph\n", "DepoDur\n", "Meconium\n", "Morphinism\n", "Moscontin\n", "Ospalivina\n", "Morfina\n", "MS Contin\n", "l-Morphine\n", "57-27-2\n", "Dulcontin\n", "Nepenthe\n", "Roxanol\n", "MORPHINE SULFATE\n", "Infumorph\n", "Dreamer\n", "Morpho\n", "Avinza\n", "Hocus\n", "Kadian\n", "Unkie\n", "Cube juice\n", "Hard stuff\n", "Oramorph SR\n", "Statex SR\n", "Ms Emma\n", "Morphin [German]\n", "Morfina [Italian]\n", "Duramorph\n", "Morphina [Italian]\n", "M-Eslon\n", "Morphine [BAN]\n", "CCRIS 5762\n", "Dolcontin\n", "HSDB 2134\n", "(5R,6S,9R,13S,14R)-4,5-Epoxy-N-methyl-7-morphinen-3,6-diol\n", "UNII-76I7G6D29C\n", "CHEBI:17303\n", "CHEMBL70\n", "EINECS 200-320-2\n", "(5alpha,6alpha)-17-methyl-7,8-didehydro-4,5-epoxymorphinan-3,6-diol\n", "4,5alpha-Epoxy-17-methyl-7-morphinen-3,6alpha-diol\n", "7,8-Didehydro-4,5-epoxy-17-methyl-morphinan-3,6-diol\n", "(7R,7AS,12BS)-3-METHYL-2,3,4,4A,7,7A-HEXAHYDRO-1H-4,12-METHANO[1]BENZOFURO[3,2-E]ISOQUINOLINE-7,9-DIOL\n", "DEA No. 9300\n", "Morphine Anhydrate\n", "76I7G6D29C\n", "Morphine (BAN)\n", "RMS\n", "(5alpha,6alpha)-Didehydro-4,5-epoxy-17-methylmorphinan-3,6-diol\n", "Morphinan-3,6-alpha-diol, 7,8-didehydro-4,5-alpha-epoxy-17-methyl-\n", "Morphinan-3,6-diol, 7,8-didehydro-4,5-epoxy-17-methyl-, (5alpha,6alpha)-\n", "9H-9,9c-Iminoethanophenanthro(4,5-bcd)furan-3,5-diol, 4a,5,7a,8-tetrahydro-12-methyl-\n", "methyl[?]diol\n", "Aguettant\n", "Dinamorf\n", "Sevredol\n", "Dimorf\n", "(5alpha,6alpha)-7,8-Didehydro-4,5-epoxy-17-methylmorphinan-3,6-diol\n", "D-(-)-Morphine\n", "Oramorph\n", "(Morphine)\n", "Substitol (TN)\n", "(4R,4aR,7S,7aR,12bS)-3-methyl-2,4,4a,7,7a,13-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol\n", "MOR\n", "(-)-(etorphine)\n", "(-)Morphine sulfate\n", "Morfina Dosa (TN)\n", "SDZ202-250\n", "NSC11441\n", "SDZ 202-250\n", "Epitope ID:116646\n", "Morphinan-3,6-diol, 7,8-didehydro-4,5-epoxy-17-methyl- (5alpha,6alpha)-\n", "SCHEMBL2997\n", "BIDD:GT0147\n", "GTPL1627\n", "DTXSID9023336\n", "Morphine 0.1 mg/ml in Methanol\n", "Morphine 1.0 mg/ml in Methanol\n", "BQJCRHHNABKAKU-KBQPJGBKSA-N\n", "ZINC3812983\n", "BDBM50000092\n", "AKOS015966554\n", "DB00295\n", "LS-91748\n", "MOI\n", "C01516\n", "D08233\n", "Q81225\n", "7,8-Didehydro-4,5-epoxy-17-methylmorphinan-3,6-diol\n", "UNII-1M5VY6ITRT component BQJCRHHNABKAKU-KBQPJGBKSA-N\n", "17-methyl-7,8-didehydro-4,5alpha-epoxymorphinan-3,6alpha-diol\n", "7,8-Didehydro-4,5-epoxy-17-methylmorphinan-3,6-diol(morphine)\n", "(5A,6A)-7,8-DIDEHYDRO-4,5-EPOXY-17-METHYLMORPHINIAN-3,6-DIOL\n", "(5alpha,6beta)-17-methyl-7,8-didehydro-4,5-epoxymorphinan-3,6-diol\n", "3-(4-Hydroxy-phenyl)-1-propyl-piperidine-3-carboxylic acid ethyl ester\n", "6-tert-Butyl-3-methyl-1,2,3,4,5,6-hexahydro-2,6-methano-benzo[d]azocine\n", "(-)(5.alpha.,6.alpha.)-7,8-Didehydro-4,5-epoxy-17-methylmorphinan-3,6-diol\n", "Morphinan-3,6-diol, 7,8-didehydro-4,5-epoxy-17-methyl- (5..alpha.,6.alpha.)-\n", "Morphine solution, 1.0 mg/mL in methanol, ampule of 1 mL, certified reference material\n", "(1S,5R,13R,14S)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol\n", "(1S,5R,13R,14S,17R)-4-methyl-12-oxa-4-azapentacyclo[9.6.1.0^{1,13}.0^{5,17}.0^{7,18}]octadeca-7(18),8,10,15-tetraene-10,14-diol\n", "(1S,5R,13R,14S,17R)-4-methyl-12-oxa-4-azapentacyclo[9.6.1.0^{1,13}.0^{5,17}.0^{7,18}]octadeca-7,9,11(18),15-tetraene-10,14-diol\n", "(morphine) 4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol\n", "2-{4-[2,4-diamino-6-pteridinylmethyl(methyl)amino]phenylcarboxamido}pentanedioic acid(morphine)\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol ; HydroChloride\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol ;sulphate salt(morphine)\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol((Morphine))\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol(morphine sulfate)\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol(morphine)\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol(Morphine)(HCl)\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol,sulfate(Morphinesulfate)\n", "4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diolMorphine\n", "4-methyl-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol\n", "4-methyl-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol (morphine)\n", "4-methyl-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol(Morphine)\n", "6,11-Dimethyl-3-(3-methyl-but-2-enyl)-1,2,3,4,5,6-hexahydro-2,6-methano-benzo[d]azocin-8-ol(Morphine)\n", "9H-9,9c-Iminoethanophenanthro(4,5-bcd)furan-3,5-diol, 4alpha,5,7alpha,8-tetrahydro-12-methyl-\n", "Morphine;4-methyl-(1S,5R,13R,14S,17R)-12-oxa-4-azapentacyclo[9.6.1.01,13.05,17.07,18]octadeca-7(18),8,10,15-tetraene-10,14-diol\n" ] } ], "source": [ "cat(content(res,\"text\",encoding=\"UTF-8\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Exercise 2a:** Retrieve (in the CSV format) the XlogP, molecular weight, hydrogen bond donor count, hydrogen\n", "bond aceptor count, and TPSA of the compounds contained in the five sdf files (link to the data files).\n", "- Use a for loop to retrieve the data for each compound.\n", "- Remember to add some sleep time (e.g 0.5 seconds) after retrieving the data for each compound.\n", "- Refer to the lecture 1 notebook to see how to merge the multiple CSV outputs into a single data frame." ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "files <- c('l02_ex2b_compound1.sdf','l02_ex2b_compound2.sdf','l02_ex2b_compound3.sdf',\n", " 'l02_ex2b_compound4.sdf','l02_ex2b_compound5.sdf')" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "# Write your code here" ] } ], "metadata": { "kernelspec": { "display_name": "R", "language": "R", "name": "ir" }, "language_info": { "codemirror_mode": "r", "file_extension": ".r", "mimetype": "text/x-r-source", "name": "R", "pygments_lexer": "r", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 4 }