rm(list = ls())
library("webchem")
data("jagst", package = "webchem")
#head(jagst)
data("lc50", package = "webchem")
#head(lc50)
dim(lc50)
## [1] 124   2
#4.3. Query identifiers
subs <- unique(jagst$substance)[1:3]
subs
## [1] "2,4-Dimethylphenol"     "4-Chlor-2-methylphenol" "4-para-nonylphenol"
ids <- get_etoxid(subs, match = "best")
ids
## # A tibble: 3 x 3
##   query                  match                  etoxid
##   <chr>                  <chr>                  <chr> 
## 1 2,4-Dimethylphenol     2,4-Xylenol            8668  
## 2 4-Chlor-2-methylphenol 4-Chlor-2-methylphenol 8494  
## 3 4-para-nonylphenol     <NA>                   <NA>
etox_data <- etox_basic(ids$etoxid)
etox_data
## $`8668`
## $`8668`$cas
## [1] "105-67-9"
## 
## $`8668`$ec
## # A tibble: 2 x 0
## 
## $`8668`$gsbl
## <unspecified> [0]
## 
## $`8668`$synonyms
## # A tibble: 5 x 2
##   name                  language 
##   <chr>                 <chr>    
## 1 2,4-Dimethylphenol    English  
## 2 2,4-dimethyl-phenol   English  
## 3 2,4-Dimethylphenol    German   
## 4 4-Hydroxy-m-xylol     German   
## 5 Phenol, 2,4-dimethyl- universal
## 
## $`8668`$source_url
## [1] "https://webetox.uba.de/webETOX/public/basics/stoff.do?language=en&id=8668"
## 
## 
## $`8494`
## $`8494`$cas
## [1] "1570-64-5"
## 
## $`8494`$ec
## # A tibble: 2 x 0
## 
## $`8494`$gsbl
## [1] "978"
## 
## $`8494`$synonyms
## # A tibble: 4 x 2
##   name                    language 
##   <chr>                   <chr>    
## 1 4-chloro-o-cresol       English  
## 2 5-Chlor-2-hydroxytoluol German   
## 3 4-Chlor-o-kresol        German   
## 4 PCOC                    universal
## 
## $`8494`$source_url
## [1] "https://webetox.uba.de/webETOX/public/basics/stoff.do?language=en&id=8494"
## 
## 
## $<NA>
## [1] NA
## 
## attr(,"class")
## [1] "etox_basic" "list"
etox_cas <- cas(etox_data)
etox_cas
##        8668        8494        <NA> 
##  "105-67-9" "1570-64-5"          NA
cids <- get_cid(etox_cas, from = "xref/rn", match = "first")
cids
## # A tibble: 3 x 2
##   query     cid  
##   <chr>     <chr>
## 1 105-67-9  7771 
## 2 1570-64-5 14855
## 3 <NA>      <NA>
pc_data <- pc_prop(cids$cid, properties = "CanonicalSMILES")
pc_data
##     CID     CanonicalSMILES
## 1  7771  CC1=CC(=C(C=C1)O)C
## 2 14855 CC1=C(C=CC(=C1)Cl)O
## 3    NA                <NA>
pc_smiles <- smiles(pc_data)
pc_smiles
## [1] "CC1=CC(=C(C=C1)O)C"  "CC1=C(C=CC(=C1)Cl)O" NA
#csids <- get_csid(pc_smiles, from = "smiles")
#cs_inchikey <- cs_convert(csids$csid, from = "csid", to = "inchikey")
res <- data.frame(name = subs, cas = etox_cas, smiles = pc_smiles,
                   cid = pc_data$CID,# inchikey = cs_inchikey, #csid = csids$csid,
                   stringsAsFactors = FALSE, row.names = NULL)
res
##                     name       cas              smiles   cid
## 1     2,4-Dimethylphenol  105-67-9  CC1=CC(=C(C=C1)O)C  7771
## 2 4-Chlor-2-methylphenol 1570-64-5 CC1=C(C=CC(=C1)Cl)O 14855
## 3     4-para-nonylphenol      <NA>                <NA>    NA
#Toxicity of different pesticide groups
lc50 <- lc50[order(lc50$value),][1:3,]
lc50
##             cas     value
## 626    563-12-2 0.0560000
## 1851 96182-53-5 0.0735453
## 968   3383-96-8 0.0770714
aw_data <- bcpc_query(lc50$cas, from = "cas")
aw_data
## $`563-12-2`
## $`563-12-2`$cname
## [1] "ethion"
## 
## $`563-12-2`$status
## [1] "ISO 1750 (published)"
## 
## $`563-12-2`$pref_iupac_name
## [1] "O,O,O′,O′-tetraethyl S,S′-methylene bis(phosphorodithioate)"
## 
## $`563-12-2`$iupac_name
## [1] "O,O,O′,O′-tetraethyl S,S′-methylene bis(phosphorodithioate)"
## 
## $`563-12-2`$cas
## [1] "563-12-2"
## 
## $`563-12-2`$formula
## [1] "C9H22O4P2S4"
## 
## $`563-12-2`$activity
## [1] "acaricides (organothiophosphate acaricides)insecticides"
## 
## $`563-12-2`$subactivity
## [1] "aliphatic organothiophosphate insecticides"
## 
## $`563-12-2`$inchikey
## [1] "RIZMRRKBZQXFOY-UHFFFAOYSA-N"
## 
## $`563-12-2`$inchi
## [1] "InChI=1S/C9H22O4P2S4/c1-5-10-14(16,11-6-2)18-9-19-15(17,12-7-3)13-8-4/h5-9H2,1-4H3"
## 
## $`563-12-2`$source_url
## [1] "https://pesticidecompendium.bcpc.org/ethion.html"
## 
## 
## $`96182-53-5`
## $`96182-53-5`$cname
## [1] "tebupirimfos"
## 
## $`96182-53-5`$status
## [1] "ISO 1750 (published)"
## 
## $`96182-53-5`$pref_iupac_name
## [1] "(Ξ)-[O-(2-tert-butylpyrimidin-5-yl) O-ethyl O-propan-2-yl phosphorothioate]"
## 
## $`96182-53-5`$iupac_name
## [1] "(RS)-[O-(2-tert-butylpyrimidin-5-yl) O-ethyl O-isopropyl phosphorothioate]"
## 
## $`96182-53-5`$cas
## [1] "96182-53-5"
## 
## $`96182-53-5`$formula
## [1] "C13H23N2O3PS"
## 
## $`96182-53-5`$activity
## [1] "insecticides"
## 
## $`96182-53-5`$subactivity
## [1] "pyrimidine organothiophosphate insecticides"
## 
## $`96182-53-5`$inchikey
## [1] "AWYOMXWDGWUJHS-UHFFFAOYSA-N"
## 
## $`96182-53-5`$inchi
## [1] "InChI=1S/C13H23N2O3PS/c1-7-16-19(20,17-10(2)3)18-11-8-14-12(15-9-11)13(4,5)6/h8-10H,7H2,1-6H3"
## 
## $`96182-53-5`$source_url
## [1] "https://pesticidecompendium.bcpc.org/tebupirimfos.html"
## 
## 
## $`3383-96-8`
## $`3383-96-8`$cname
## [1] "temephos"
## 
## $`3383-96-8`$status
## [1] "ISO 1750 (published)"
## 
## $`3383-96-8`$pref_iupac_name
## [1] "O,O,O′,O′-tetramethyl O,O′-(sulfanediyldi-4,1-phenylene) bis(phosphorothioate)"
## 
## $`3383-96-8`$iupac_name
## [1] "O,O,O′,O′-tetramethyl O,O′-(thiodi-p-phenylene) bis(phosphorothioate)orO,O,O′,O′-tetramethyl O,O′-(thiodi-p-phenylene) diphosphorothioate"
## 
## $`3383-96-8`$cas
## [1] "3383-96-8"
## 
## $`3383-96-8`$formula
## [1] "C16H20O6P2S3"
## 
## $`3383-96-8`$activity
## [1] "insecticides"
## 
## $`3383-96-8`$subactivity
## [1] "phenyl organothiophosphate insecticides"
## 
## $`3383-96-8`$inchikey
## [1] "WWJZWCUNLNYYAU-UHFFFAOYSA-N"
## 
## $`3383-96-8`$inchi
## [1] "InChI=1S/C16H20O6P2S3/c1-17-23(25,18-2)21-13-5-9-15(10-6-13)27-16-11-7-14(8-12-16)22-24(26,19-3)20-4/h5-12H,1-4H3"
## 
## $`3383-96-8`$source_url
## [1] "https://pesticidecompendium.bcpc.org/temephos.html"
## 
## 
## attr(,"class")
## [1] "bcpc_query" "list"
igroup <- sapply(aw_data, function(y) {
   if (is(y, "list")) y$subactivity[1] else NA_character_
   })
igroup
##                                      563-12-2 
##  "aliphatic organothiophosphate insecticides" 
##                                    96182-53-5 
## "pyrimidine organothiophosphate insecticides" 
##                                     3383-96-8 
##     "phenyl organothiophosphate insecticides"
#Identify common names and roles of chemicals
cas_rns <- lc50[order(lc50$value)[1:3], "cas"]
cas_rns
## [1] "563-12-2"   "96182-53-5" "3383-96-8"
chebiids <- get_chebiid(cas_rns)
chebiids 
## # A tibble: 3 x 5
##   query      chebiid     chebiasciiname searchscore entitystar
##   <chr>      <chr>       <chr>          <chr>       <chr>     
## 1 563-12-2   CHEBI:38663 ethion         0.5         3         
## 2 96182-53-5 CHEBI:38951 tebupirimfos   0.55        3         
## 3 3383-96-8  CHEBI:38954 temephos       0.48        3
comp <- chebi_comp_entity(chebiids$chebiid)
pars <- lapply(comp, function(x)
  with(x, parents))
pars
## $`CHEBI:38663`
##                                     chebiName     chebiId     type  status
## 1                                 insecticide CHEBI:24852 has role CHECKED
## 2                   environmental contaminant CHEBI:78298 has role CHECKED
## 3 EC 3.1.1.7 (acetylcholinesterase) inhibitor CHEBI:38462 has role CHECKED
## 4                       organic thiophosphate CHEBI:37512     is a CHECKED
## 5                                   acaricide CHEBI:22153 has role CHECKED
## 6                                agrochemical CHEBI:33286 has role CHECKED
##   cyclicRelationship
## 1              false
## 2              false
## 3              false
## 4              false
## 5              false
## 6              false
## 
## $`CHEBI:38951`
##                                     chebiName     chebiId                  type
## 1 EC 3.1.1.7 (acetylcholinesterase) inhibitor CHEBI:38462              has role
## 2                       organic thiophosphate CHEBI:37512                  is a
## 3             organothiophosphate insecticide CHEBI:25715                  is a
## 4                  2-tert-butylpyrimidin-5-ol CHEBI:38952 has functional parent
##    status cyclicRelationship
## 1 CHECKED              false
## 2 CHECKED              false
## 3 CHECKED              false
## 4 CHECKED              false
## 
## $`CHEBI:38954`
##                                     chebiName     chebiId                  type
## 1                             organic sulfide CHEBI:16385                  is a
## 2 EC 3.1.1.7 (acetylcholinesterase) inhibitor CHEBI:38462              has role
## 3                       organic thiophosphate CHEBI:37512                  is a
## 4             organothiophosphate insecticide CHEBI:25715                  is a
## 5                                   acaricide CHEBI:22153              has role
## 6                                agrochemical CHEBI:33286              has role
## 7                            ectoparasiticide CHEBI:38956              has role
## 8                           4,4'-thiodiphenol CHEBI:38957 has functional parent
##    status cyclicRelationship
## 1 CHECKED              false
## 2 CHECKED              false
## 3 CHECKED              false
## 4 CHECKED              false
## 5 CHECKED              false
## 6 CHECKED              false
## 7 CHECKED              false
## 8 CHECKED              false
str(pars)
## List of 3
##  $ CHEBI:38663:'data.frame': 6 obs. of  5 variables:
##   ..$ chebiName         : chr [1:6] "insecticide" "environmental contaminant" "EC 3.1.1.7 (acetylcholinesterase) inhibitor" "organic thiophosphate" ...
##   ..$ chebiId           : chr [1:6] "CHEBI:24852" "CHEBI:78298" "CHEBI:38462" "CHEBI:37512" ...
##   ..$ type              : chr [1:6] "has role" "has role" "has role" "is a" ...
##   ..$ status            : chr [1:6] "CHECKED" "CHECKED" "CHECKED" "CHECKED" ...
##   ..$ cyclicRelationship: chr [1:6] "false" "false" "false" "false" ...
##  $ CHEBI:38951:'data.frame': 4 obs. of  5 variables:
##   ..$ chebiName         : chr [1:4] "EC 3.1.1.7 (acetylcholinesterase) inhibitor" "organic thiophosphate" "organothiophosphate insecticide" "2-tert-butylpyrimidin-5-ol"
##   ..$ chebiId           : chr [1:4] "CHEBI:38462" "CHEBI:37512" "CHEBI:25715" "CHEBI:38952"
##   ..$ type              : chr [1:4] "has role" "is a" "is a" "has functional parent"
##   ..$ status            : chr [1:4] "CHECKED" "CHECKED" "CHECKED" "CHECKED"
##   ..$ cyclicRelationship: chr [1:4] "false" "false" "false" "false"
##  $ CHEBI:38954:'data.frame': 8 obs. of  5 variables:
##   ..$ chebiName         : chr [1:8] "organic sulfide" "EC 3.1.1.7 (acetylcholinesterase) inhibitor" "organic thiophosphate" "organothiophosphate insecticide" ...
##   ..$ chebiId           : chr [1:8] "CHEBI:16385" "CHEBI:38462" "CHEBI:37512" "CHEBI:25715" ...
##   ..$ type              : chr [1:8] "is a" "has role" "is a" "is a" ...
##   ..$ status            : chr [1:8] "CHECKED" "CHECKED" "CHECKED" "CHECKED" ...
##   ..$ cyclicRelationship: chr [1:8] "false" "false" "false" "false" ...
#Querying partitioning coefficients
cid <- get_cid(lc50$cas, from = "xref/rn", match = "first")
cid 
## # A tibble: 3 x 2
##   query      cid  
##   <chr>      <chr>
## 1 563-12-2   3286 
## 2 96182-53-5 93516
## 3 3383-96-8  5392
pc_data <- pc_prop(cid$cid)
pc_data 
##     CID MolecularFormula MolecularWeight
## 1  3286      C9H22O4P2S4           384.5
## 2 93516     C13H23N2O3PS          318.37
## 3  5392     C16H20O6P2S3           466.5
##                                       CanonicalSMILES
## 1                       CCOP(=S)(OCC)SCSP(=S)(OCC)OCC
## 2              CCOP(=S)(OC1=CN=C(N=C1)C(C)(C)C)OC(C)C
## 3 COP(=S)(OC)OC1=CC=C(C=C1)SC2=CC=C(C=C2)OP(=S)(OC)OC
##                                        IsomericSMILES
## 1                       CCOP(=S)(OCC)SCSP(=S)(OCC)OCC
## 2              CCOP(=S)(OC1=CN=C(N=C1)C(C)(C)C)OC(C)C
## 3 COP(=S)(OC)OC1=CC=C(C=C1)SC2=CC=C(C=C2)OP(=S)(OC)OC
##                                                                                                               InChI
## 1                                InChI=1S/C9H22O4P2S4/c1-5-10-14(16,11-6-2)18-9-19-15(17,12-7-3)13-8-4/h5-9H2,1-4H3
## 2                     InChI=1S/C13H23N2O3PS/c1-7-16-19(20,17-10(2)3)18-11-8-14-12(15-9-11)13(4,5)6/h8-10H,7H2,1-6H3
## 3 InChI=1S/C16H20O6P2S3/c1-17-23(25,18-2)21-13-5-9-15(10-6-13)27-16-11-7-14(8-12-16)22-24(26,19-3)20-4/h5-12H,1-4H3
##                      InChIKey
## 1 RIZMRRKBZQXFOY-UHFFFAOYSA-N
## 2 AWYOMXWDGWUJHS-UHFFFAOYSA-N
## 3 WWJZWCUNLNYYAU-UHFFFAOYSA-N
##                                                                                            IUPACName
## 1             diethoxyphosphinothioylsulfanylmethylsulfanyl-diethoxy-sulfanylidene-lambda5-phosphane
## 2              (2-tert-butylpyrimidin-5-yl)oxy-ethoxy-propan-2-yloxy-sulfanylidene-lambda5-phosphane
## 3 [4-(4-dimethoxyphosphinothioyloxyphenyl)sulfanylphenoxy]-dimethoxy-sulfanylidene-lambda5-phosphane
##   XLogP    ExactMass MonoisotopicMass  TPSA Complexity Charge HBondDonorCount
## 1   5.1 383.98761787     383.98761787 152.0        279      0               0
## 2   4.2 318.11670077     318.11670077  85.6        339      0               0
## 3   6.0 465.98972587     465.98972587 145.0        474      0               0
##   HBondAcceptorCount RotatableBondCount HeavyAtomCount IsotopeAtomCount
## 1                  8                 12             19                0
## 2                  6                  7             20                0
## 3                  9                 10             27                0
##   AtomStereoCount DefinedAtomStereoCount UndefinedAtomStereoCount
## 1               0                      0                        0
## 2               1                      0                        1
## 3               0                      0                        0
##   BondStereoCount DefinedBondStereoCount UndefinedBondStereoCount
## 1               0                      0                        0
## 2               0                      0                        0
## 3               0                      0                        0
##   CovalentUnitCount Volume3D XStericQuadrupole3D YStericQuadrupole3D
## 1                 1    272.4                9.91                4.78
## 2                 1    244.6               12.00                2.92
## 3                 1    330.5               16.56                4.71
##   ZStericQuadrupole3D FeatureCount3D FeatureAcceptorCount3D FeatureDonorCount3D
## 1                1.71              0                      0                   0
## 2                1.22              5                      1                   0
## 3                1.92              2                      0                   0
##   FeatureAnionCount3D FeatureCationCount3D FeatureRingCount3D
## 1                   0                    0                  0
## 2                   0                    1                  1
## 3                   0                    0                  2
##   FeatureHydrophobeCount3D ConformerModelRMSD3D EffectiveRotorCount3D
## 1                        0                  1.0                    12
## 2                        2                  0.8                     7
## 3                        0                  1.0                    10
##   ConformerCount3D
## 1               10
## 2               10
## 3               10
##                                                                                                                                                  Fingerprint2D
## 1 AAADceBwOANwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGgQAACAAAACggAKCAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
## 2 AAADceBzMAJAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAABgAAAHgAAACAADhThkwYvlpYIERCgABJnZASAgCkRQKABUCArRBCCCIBASUAEBAgIAALQACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
## 3 AAADceB4OANgAAAAAAAAAAAAAAAAAAAAAAAwYAAAAAAAAAABQAAAGgQAACAACASA0AIyB4AAARiAACBCAAACAAAgKBAIiBgGCIgIJiKgERKAMAAkwBEoiAeAQAAAAIAAAAAAAAABAAAAAAAAAAAAAAAAAA==
lc50$logp <- pc_data$XLogP
#Regulatory information
eqs <- etox_targets(ids$etoxid)
ids$etoxid
##            2,4-Xylenol 4-Chlor-2-methylphenol                        
##                 "8668"                 "8494"                     NA
eqs
## $`8668`
## $`8668`$res
##   ETOX_ID_NR   Substance   CAS_NO     EC_NO ETOX_ID_NO_Substance
## 1        891 2,4-Xylenol 105-67-9 203-321-6                 8668
## 2        892 2,4-Xylenol 105-67-9 203-321-6                 8668
## 3       2091 2,4-Xylenol 105-67-9 203-321-6                 8668
## 4       2092 2,4-Xylenol 105-67-9 203-321-6                 8668
## 5       2093 2,4-Xylenol 105-67-9 203-321-6                 8668
##   Country_or_Region County Medium Status Protected_Asset Use Protection_Level
## 1               USA      -     AQ     QC       AQL-FRESH  NA             n.s.
## 2               USA      -     AQ     QC       AQL-MARIN  NA             n.s.
## 3               USA      -     AQ     QC      DRINK-FISH  NA             n.s.
## 4               USA      -     AQ     QC      FISH-CONSM  NA             n.s.
## 5               USA      -     AQ     QC       GESCHMACK  NA             n.s.
##   Institution Designation Operator Value_Target_LR Value_Target_UR Unit
## 1     EPA_USA         CCC       NA           530.0               0 μg/l
## 2     EPA_USA         CCC       NA           110.0               0 μg/l
## 3     EPA_USA         WQC       NA           540.0               0 μg/l
## 4     EPA_USA         WQC       NA             2.3               0 μg/l
## 5     EPA_USA         WQC       NA           400.0               0 μg/l
##   Concentration_Specification Concentration_Specification.Monitoring Remark
## 1                                                   four-day average     NA
## 2                                                   four-day average     NA
## 3                           -                                      -     NA
## 4                           -                                      -     NA
## 5                           -                                      -     NA
##   Derivation_Base Derivation_Method Note Target_Description
## 1              NA                NA   NA                 NA
## 2              NA                NA   NA                 NA
## 3              NA                NA   NA                 NA
## 4              NA                NA   NA                 NA
## 5              NA                NA   NA                 NA
##   ETOX_ID_NO_Reference   Author Year
## 1                 1350 U.S. EPA 1993
## 2                 1350 U.S. EPA 1993
## 3                 1362 U.S. EPA 1999
## 4                 1362 U.S. EPA 1999
## 5                 1362 U.S. EPA 1999
##                                                                                               Title
## 1 Ambient aquatic life water quality criteria for 2,4-Dimethylphenol (CAS Registry Number 105-67-9)
## 2 Ambient aquatic life water quality criteria for 2,4-Dimethylphenol (CAS Registry Number 105-67-9)
## 3                                           National recommended water quality criteria-correction.
## 4                                           National recommended water quality criteria-correction.
## 5                                           National recommended water quality criteria-correction.
##   Journal Volume Pages
## 1      NA     NA    NA
## 2      NA     NA    NA
## 3      NA     NA    NA
## 4      NA     NA    NA
## 5      NA     NA    NA
##                                                                                                                                                                                                                       Source
## 1                                                                                                                                                                                               U.S. EPA, NTIS: PB 94-118551
## 2                                                                                                                                                                                               U.S. EPA, NTIS: PB 94-118551
## 3 United States Environmental Protection Agency. Washington, DC. Office of Water. EPA-822-Z-99-001. PB99-149189. Updates are available. Please look up: https://www.epa.gov/wqc/national-recommended-water-quality-criteria.
## 4 United States Environmental Protection Agency. Washington, DC. Office of Water. EPA-822-Z-99-001. PB99-149189. Updates are available. Please look up: https://www.epa.gov/wqc/national-recommended-water-quality-criteria.
## 5 United States Environmental Protection Agency. Washington, DC. Office of Water. EPA-822-Z-99-001. PB99-149189. Updates are available. Please look up: https://www.epa.gov/wqc/national-recommended-water-quality-criteria.
## 
## $`8668`$source_url
## [1] "https://webetox.uba.de/webETOX/public/basics/stoff/ziel.do?stoff=6203&language=en"
## 
## 
## $`8494`
## $`8494`$res
##   ETOX_ID_NR              Substance    CAS_NO EC_NO ETOX_ID_NO_Substance
## 1       4639 4-Chlor-2-methylphenol 1570-64-5    NA                 8494
## 2       4990 4-Chlor-2-methylphenol 1570-64-5    NA                 8494
##   Country_or_Region County Medium Status Protected_Asset Use Protection_Level
## 1          EEC / EU      -     AQ     QC       AQL-FRESH  NA               NA
## 2               NLD      -     AQ     QC       AQL-FRESH  NA               NA
##   Institution Designation Operator Value_Target_LR Value_Target_UR Unit
## 1                    PNEC        =              50               0 μg/l
## 2     RIVM_NL         MTR                       50               0 μg/l
##   Concentration_Specification Concentration_Specification.Monitoring Remark
## 1                          NA                                     NA     NA
## 2                          NA                                     NA     NA
##   Derivation_Base Derivation_Method Note Target_Description
## 1              NA             AF=10   NA                 NA
## 2              NA                     NA                 NA
##   ETOX_ID_NO_Reference
## 1                24181
## 2                24276
##                                                                                                                       Author
## 1 European Commission ? Joint Research Centre\nInstitute for Health and Consumer Protection\nEuropean Chemicals Bureau (ECB)
## 2                                                                                                 Janus, J.A., Posthumus, R.
##   Year
## 1   NA
## 2   NA
##                                                                                                  Title
## 1    European Union Risk Assessment Report: 4-chloro-o-cresol CAS No: 1570-64-5 , EINECS No: 216-381-3
## 2 Environmental Risk Limits for 2-propanol, formaldehyde and 4-chloromethylphenols - updated proposals
##   Journal Volume Pages
## 1      NA     NA    NA
## 2      NA     NA    NA
##                                                                               Source
## 1 OFFICE FOR OFFICIAL PUBLICATIONS\nOF THE EUROPEAN COMMUNITIES\nL ? 2985 Luxembourg
## 2                                                         RIVM report 601501015/2002
## 
## $`8494`$source_url
## [1] "https://webetox.uba.de/webETOX/public/basics/stoff/ziel.do?stoff=6065&language=en"
## 
## 
## $<NA>
## [1] NA
#View(do.call("rbind",eqs))
ids$mac <- sapply(eqs, function(y) {
   if (is(y, "list")) {
     min(subset(y$res)[["Value_Target_LR"]])
     } else NA_real_
   })
ids
## # A tibble: 3 x 4
##   query                  match                  etoxid   mac
##   <chr>                  <chr>                  <chr>  <dbl>
## 1 2,4-Dimethylphenol     2,4-Xylenol            8668     2.3
## 2 4-Chlor-2-methylphenol 4-Chlor-2-methylphenol 8494    50  
## 3 4-para-nonylphenol     <NA>                   <NA>    NA
(mac <- with(ids, ids[!is.na(mac) & is.finite(mac), c("etoxid", "query",
                                                       "mac")]))
## # A tibble: 2 x 3
##   etoxid query                    mac
##   <chr>  <chr>                  <dbl>
## 1 8668   2,4-Dimethylphenol       2.3
## 2 8494   4-Chlor-2-methylphenol  50
jagst_eqs <- merge(jagst, mac, by.x = "substance", by.y = "query")
jagst_eqs
##                 substance       date value qual etoxid  mac
## 1      2,4-Dimethylphenol 2013-01-04 0.006    <   8668  2.3
## 2      2,4-Dimethylphenol 2013-01-29 0.006    <   8668  2.3
## 3      2,4-Dimethylphenol 2013-02-26 0.006    <   8668  2.3
## 4      2,4-Dimethylphenol 2013-03-26 0.006    <   8668  2.3
## 5      2,4-Dimethylphenol 2013-04-23 0.006    <   8668  2.3
## 6      2,4-Dimethylphenol 2013-05-22 0.006    <   8668  2.3
## 7      2,4-Dimethylphenol 2013-06-18 0.006    <   8668  2.3
## 8      2,4-Dimethylphenol 2013-07-16 0.006    <   8668  2.3
## 9      2,4-Dimethylphenol 2013-08-13 0.006    =   8668  2.3
## 10     2,4-Dimethylphenol 2013-09-10 0.006    =   8668  2.3
## 11     2,4-Dimethylphenol 2013-10-08 0.006    <   8668  2.3
## 12     2,4-Dimethylphenol 2013-11-05 0.006    <   8668  2.3
## 13     2,4-Dimethylphenol 2013-12-03 0.006    <   8668  2.3
## 14 4-Chlor-2-methylphenol 2013-01-04 0.006    <   8494 50.0
## 15 4-Chlor-2-methylphenol 2013-01-29 0.007    =   8494 50.0
## 16 4-Chlor-2-methylphenol 2013-02-26 0.006    <   8494 50.0
## 17 4-Chlor-2-methylphenol 2013-03-26 0.006    <   8494 50.0
## 18 4-Chlor-2-methylphenol 2013-04-23 0.006    <   8494 50.0
## 19 4-Chlor-2-methylphenol 2013-05-22 0.006    <   8494 50.0
## 20 4-Chlor-2-methylphenol 2013-06-18 0.006    <   8494 50.0
## 21 4-Chlor-2-methylphenol 2013-07-16 0.006    <   8494 50.0
## 22 4-Chlor-2-methylphenol 2013-08-13 0.006    <   8494 50.0
## 23 4-Chlor-2-methylphenol 2013-09-10 0.006    <   8494 50.0
## 24 4-Chlor-2-methylphenol 2013-10-08 0.006    <   8494 50.0
## 25 4-Chlor-2-methylphenol 2013-11-05 0.006    <   8494 50.0
## 26 4-Chlor-2-methylphenol 2013-12-03 0.006    <   8494 50.0
# Utility functions
is.inchikey("BQJCRHHNABKAKU-KBQPJGBKS-AN")
## [1] FALSE
is.cas("64-17-6")
## 64-17-6 
##   FALSE
is.inchikey("BQJCRHHNABKAKU-KBQPJGBKSA-5", type = "chemspider")
## [1] FALSE
#ref https://www.jstatsoft.org/article/view/v093i13
#https://cran.r-project.org/web/packages/webchem/vignettes/webchem.html