options(repos="https://ftp.yz.yamagata-u.ac.jp/pub/cran/")
if(!require("BiocManager",quietly=T)){install.packages("BiocManager")}
x <- c("ChemmineR","ChemmineOB");for(i in x){
  if(!require(i,character.only=T)){
    BiocManager::install(i);library(i,character.only=T)}};rm(x,i)
sdfset<-read.SDFset("DataChemicalStructure.sdf")
cidData<-cid(sdfset)   #cid named by Chemmine.R
cidData
charS<-as.character()
for (i in 1:20) {
smilesdata<-sdf2smiles(sdfset[i])
charS[i]<-as.character(smilesdata)
}
#-------------------
sdfset[[1]]
sdfset[[1]][[4]]
ntag<-length(sdfset[[1]][[4]])
ntag
taglist<-list()
for(i in 1:ntag){
taglist[[i]]<-datablocktag(sdfset,tag=i)
}
tabledata<-data.frame(taglist[[2]],taglist[[1]],taglist[[3]],charS)
colnames(tabledata)<-c("KNApSAcKID","Name","StC","SMILES" )
write.csv(row.names=FALSE,tabledata,"DataTableChemicalStructure.csv")