Hi,
I’m writing an application that acts as front-end to a command line tool called OpenBabel and whilst the current application works fine I can see potential problems with updating and extending it.
The problem area is :-
There are two dropdown menus, the user selects an item from the first menu “classes” this then populates the second menu, the user then selects from the second menu this then populates a text field with a SMARTS string (a text string representing a chemical search query). As I said this works but at the moment if I want to edit or add another SMARTS string I have to edit the property list and add the text string to the series of if/then shown at the end of the portion of code.
It would be smarter if I could have the SMARTS string in the property list with the menu items but I can’t think of how to do this?
All help very welcome.
Chris
–property obgrep_options : {“choose”, “-v Invert match”, “-c Print Number Matching”, “-f Full Match”, “-n Print Name”, “-t Pattern Repeat”}
property the_input_file : “”
property the_output_file : “”
property the_obgrep_command : “”
property the_obgrep_command_shell : “”
property use_terminal : false
property the_result : {}
property the_obgrep_txt : “”
property the_SMILES : “”
property num_repeat : 0
property group_1 : {“Choose”, “Nitrogen”, “Carbon”, “Oxygen”, “Halogen”, “Sulphur”, “Carbonyl”, “Acid”, “Base”, “Aryl”, “AminoAcid”, “Misc”}
property input_menu_Nitrogen : {“amine”, “primary”, “secondary”, “tertiary”, “hydroxylamine”, “enamine”, “oxime”, “imino”, “nitro”, “nitrile”, “isothiocyanate”, “isocyanate”, “hydrazone”, “hydrazine”, “carbamate”, “thiocarbamate”, “azo”, “triazine”, “azide”, “unsub_aniline”, “aniline”, “amide”, “lactam”, “urea”, “amidine”, “guanidine”}
property input_menu_Carbon : {“alkyl”, “alkene”, “alkyne”, “aryl”, “enol_ether”, “enamine”}
property input_menu_Oxygen : {“hydroxyl”, “alcohol”, “enol_ether”, “hemi_acetal”, “hemiketal”, “acetal”, “ketal”, “ether”, “phenol”, “peroxide”, “epoxide”, “ketone”, “aldehyde”, “lactone”, “ester”, “ester”, “carboxylic_acid”, “carbamate”, “anhydride”}
property input_menu_Halogen : {“halide”, “sulphonyl_halide”, “aryl_halide”, “alkyl_halide”, “acid_chloride”, “acid_halide”, “aryl_mono_BrI”}
property input_menu_Sulphur : {“mercapto”, “dithioacetal”, “sulphonyl_halide”, “sulphonamide”, “thioether”, “disulphide”, “sulphide”, “sulphoxide”, “sulphone”, “thiol”, “thioester”, “thiourea”}
property input_menu_Carbonyl : {“ketone”, “aldehyde”, “ester”, “carbonyl”, “lactone”, “carboxylic_acid”, “acid_chloride”, “acid_halide”, “amide”, “lactam”, “urea”, “thiocarbonyl”, “thioester”, “thioamide”}
property input_menu_Acid : {“acid”, “carboxylic_acid”, “sulphonic_acid”, “phosphonic_acid”, “phosphoric_acid”, “carbamic_acids”, “carbonate”, “tetrazole”, “malonic”, “acylsulphonamide”}
property input_menu_Base : {“base”, “primary_amine”, “sec_amine”, “tert_amine”, “amidine”, “guanidine”, “pyridine”}
property input_menu_Aryl : {“aryl”, “benzene_ring”, “aryl_halide”, “phenol”, “unsub_aniline”, “aniline”, “aryl_mono_BrI”}
property input_menu_AminoAcid : {“glycine”, “alanine”, “valine”, “leucine”, “isoleucine”, “phenylalanine”, “aspargine”, “glutamine”, “tryptophan”, “proline”, “serine”, “threonine”, “tyrosine”, “cysteine”, “methonine”, “aspartate”, “glutamate”, “lysine”, “arginine”, “histidine”}
property input_menu_Misc : {“Choose”, “aryl”, “hetatm”, “ring”, “charge”, “anion”, “cation”, “acceptor”, “hydrophobic”, “hydrophilic”, “aromatic”, “donor”}
property input_menu_2_choice : {}
on choose menu item theObject
if the name of theObject = “classes” then
tell window “main”
set the_menu_1 to title of popup button "classes" of tab view item "Search" of tab view "nstab"
--display dialog the_menu_1
if the_menu_1 = "Nitrogen" then
set input_menu_2_choice to input_menu_Nitrogen
end if
if the_menu_1 = "Carbon" then
set input_menu_2_choice to input_menu_Carbon
end if
if the_menu_1 = "Oxygen" then
set input_menu_2_choice to input_menu_Oxygen
end if
if the_menu_1 = "Halogen" then
set input_menu_2_choice to input_menu_Halogen
end if
if the_menu_1 = "Sulphur" then
set input_menu_2_choice to input_menu_Sulphur
end if
if the_menu_1 = "Carbonyl" then
set input_menu_2_choice to input_menu_Carbonyl
end if
if the_menu_1 = "Acid" then
set input_menu_2_choice to input_menu_Acid
end if
if the_menu_1 = "Base" then
set input_menu_2_choice to input_menu_Base
end if
if the_menu_1 = "Aryl" then
set input_menu_2_choice to input_menu_Aryl
end if
if the_menu_1 = "AminoAcid" then
set input_menu_2_choice to input_menu_AminoAcid
end if
if the_menu_1 = "Misc" then
set input_menu_2_choice to input_menu_Misc
end if
delete every menu item of menu of popup button "groups" of tab view item "Search" of tab view "nstab"
repeat with i in my input_menu_2_choice
make new menu item at the end of menu items of menu of popup button "groups" of tab view item "Search" of tab view "nstab" with properties {title:i, enabled:true}
end repeat
end tell
end if
if the name of theObject = "groups" then
tell window "main"
set the_menu_2 to title of popup button "groups" of tab view item "Search" of tab view "nstab"
--display dialog the_menu_2
--Nitrogen
if the_menu_2 = "amine" then
set contents of text field "SMILES_string" of tab view item "Search" of tab view "nstab" to "[N;!$(N*=[!#6]);!$(N~[!#6]);!$(Na);!$(N#*);!$(N=*)]"
end if
if the_menu_2 = "primary" then
set contents of text field "SMILES_string" of tab view item "Search" of tab view "nstab" to "[$([$([N;!$(N*=[!#6]);!$(N~[!#6]);!$(Na);!$(N#*);!$(N=*)]);D1])]"
end if
if the_menu_2 = "secondary" then
set contents of text field "SMILES_string" of tab view item "Search" of tab view "nstab" to "[$([$([N;!$(N*=[!#6]);!$(N~[!#6]);!$(Na);!$(N#*);!$(N=*)]);D2])]"
end if
etc…