Skip to content

Commit

Permalink
make Fragment parsed by adjacency list
Browse files Browse the repository at this point in the history
  • Loading branch information
lily90502 authored and hwpang committed Oct 4, 2023
1 parent ad91e7b commit d330613
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/Parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,15 @@ getatomdictsmiles(smiles) = getatomdictfromrdkit(Chem.AddHs(Chem.MolFromSmiles(s
export getatomdictsmiles
getatomdictinchi(inchi) = getatomdictfromrdkit(Chem.AddHs(Chem.MolFromInchi(inchi)))
export getatomdictinchi
getatomdictadjlist(adjlist) = getatomdictfromrmg(molecule.Molecule().from_adjacency_list(adjlist))
function getatomdictadjlist(adjlist)
try
getatomdictfromrmg(molecule.Molecule().from_adjacency_list(adjlist))
catch
mol = species.Species().from_adjacency_list(adjlist).molecule[1]
mol.assign_representative_molecule()
getatomdictfromrmg(mol.mol_repr)
end
end
export getatomdictadjlist

function getspeciesradius(atomdict,nbonds::Int64)
Expand Down Expand Up @@ -288,11 +296,11 @@ function readinputyml(fname::String)
#attempt to generate molecular information from rdkit if possible
if !("atomnums" in keys(d)) || !("bondnum" in keys(d)) || !("molecularweight" in keys(d))
if "adjlist" in keys(d)
try
d["atomnums"],d["bondnum"],d["molecularweight"] = getatomdictadjlist(d["adjlist"])
catch
@warn("failed to generate molecular information from smiles for species $spcname")
end
# try
d["atomnums"],d["bondnum"],d["molecularweight"] = getatomdictadjlist(d["adjlist"])
# catch
# @warn("failed to generate molecular information from adjlist for species $spcname")
# end
elseif "smiles" in keys(d)
try
d["atomnums"],d["bondnum"],d["molecularweight"] = getatomdictsmiles(d["smiles"])
Expand Down

0 comments on commit d330613

Please sign in to comment.