diff --git a/.gitignore b/.gitignore index 6172951..ed281c4 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,8 @@ __pycache__ run_search.build run_search.dist -run_search.onefile-build \ No newline at end of file +run_search.onefile-build +ProteoRift-main +config.ini +env.json +maestro-* \ No newline at end of file diff --git a/README.md b/README.md index 8867db2..fe816c9 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,9 @@ Download installer.bin from release Require Dependencies >= Ubuntu 20.04 ``` sudo apt install build-essential fuse +``` +Now Run the Installer ``` chmod +x installer.bin ./installer.bin diff --git a/electron-app/env.json b/electron-app/env.json deleted file mode 100644 index c97a437..0000000 --- a/electron-app/env.json +++ /dev/null @@ -1,5 +0,0 @@ -{ -"VITE_SPECOLLATE":"/home/syntist/Documents/MAESTRO/.python/bin/python3 /home/syntist/Documents/MAESTRO/SpeCollate/run_search.py", -"VITE_MODEL":"/home/syntist/Documents/MAESTRO/models/specollate_model_weights.pt", -"VITE_CONFIG":"/home/syntist/Documents/MAESTRO/config.ini" -} \ No newline at end of file diff --git a/electron-app/src/main/index.ts b/electron-app/src/main/index.ts index 8515487..c4a13be 100644 --- a/electron-app/src/main/index.ts +++ b/electron-app/src/main/index.ts @@ -11,13 +11,13 @@ if (fs.existsSync(path.resolve(process.cwd(), '../../env.json'))) { configPath = path.resolve(process.cwd(), '../../env.json') } else if (fs.existsSync(path.resolve(process.cwd(), './env.json'))) { configPath = path.resolve(process.cwd(), './env.json') +} else if (fs.existsSync(path.resolve(process.cwd(), '../env.json'))) { + configPath = path.resolve(process.cwd(), '../env.json') } else { console.log('env.json can not be found, exiting') process.exit() } -console.log(configPath) - const rawData = fs.readFileSync(configPath, 'utf-8') const config = JSON.parse(rawData) diff --git a/electron-app/src/renderer/src/App.tsx b/electron-app/src/renderer/src/App.tsx index 50ec6e0..9354e88 100644 --- a/electron-app/src/renderer/src/App.tsx +++ b/electron-app/src/renderer/src/App.tsx @@ -6,7 +6,7 @@ import { Runner } from './components/Runner' const specollate = `${await window.electron.getEnvVariable('SPECOLLATE')} -c ${await window.electron.getEnvVariable('SPECOLLATE_CONFIG')}` -console.log(specollate) +const proteorift = `${await window.electron.getEnvVariable('PROTEORIFT')} -c ${await window.electron.getEnvVariable('SPECOLLATE_CONFIG')}` function App(): JSX.Element { const [show, setShow] = useState(false) @@ -14,9 +14,9 @@ function App(): JSX.Element { const runCommand = (gpu: boolean) => { setShow(true) if (gpu) { - window.electron.runCmd(`${specollate} -u gpu`) + window.electron.runCmd(`${proteorift} -u gpu`) } else { - window.electron.runCmd(specollate) + window.electron.runCmd(proteorift) } } diff --git a/electron-app/src/renderer/src/components/ConfigForm/index.tsx b/electron-app/src/renderer/src/components/ConfigForm/index.tsx index d240571..7433d27 100644 --- a/electron-app/src/renderer/src/components/ConfigForm/index.tsx +++ b/electron-app/src/renderer/src/components/ConfigForm/index.tsx @@ -13,7 +13,7 @@ import { Checkbox } from '@mui/material' import FolderSelector from '../FolderSelector' -import { configBuilder } from '@renderer/utils/helper' +import { configBuilder, configBuilderV2 } from '@renderer/utils/helper' import { useState } from 'react' const ConfigForm = ({ run }: any) => { @@ -44,7 +44,7 @@ const ConfigForm = ({ run }: any) => { console.log(errors) const onSubmit = (data) => { - configBuilder(data) + configBuilderV2(data) run() } diff --git a/electron-app/src/renderer/src/utils/helper.tsx b/electron-app/src/renderer/src/utils/helper.tsx index 3d68c41..578f249 100644 --- a/electron-app/src/renderer/src/utils/helper.tsx +++ b/electron-app/src/renderer/src/utils/helper.tsx @@ -1,5 +1,6 @@ -const MODEL = import.meta.env.VITE_MODEL -const CONFIG = import.meta.env.VITE_CONFIG +const MODEL = await window.electron.getEnvVariable('MODEL') +const MODEL_2 = await window.electron.getEnvVariable('MODEL_2') +const CONFIG = await window.electron.getEnvVariable('SPECOLLATE_CONFIG') export const configBuilder = async (data: any) => { const config = ` @@ -102,3 +103,136 @@ batch_size : 1024 ` await window.electron.ipcRenderer.invoke('write-file', CONFIG, config) } + + +export const configBuilderV2 = async (data: any) => { + const config = ` +[preprocess] + +# For raptor +# in_tensor_dir : ./data/train-ready/pred-full/ + +# For comet +# in_tensor_dir : /scratch/mtari008/37154933/pred-full-deepnovo/ + +# For expanse +in_tensor_dir : /lclhome/mtari008/job_2436627/nist_massiv_80k_ch_graymass/ + +############ INPUT PARAMETERS ############ +[input] + +# file paths +mgf_dir : /lclhome/mtari008/data/spectra/labeled/fruitfly.PXD004120 +prep_dir: sample_data/preprocess_files + +; val_dir : /lclhome/mtari008/data/deepatles/train_ready/nist-masive-deepnovo-5k-ch1-3-len7-30-200-mod-mass + +# The array size to store a spectrum. +spec_size : 50000 + +# Max charge value to be used to read spectrum files. +charge : 5 + +# Whether to use modifications or not. +use_mods : True + +# Max mods per peptide +num_mods: 5 + +# Number of species the training dataset contains. +num_species : 9 + +master_port : 12347 + +rank : 1 + +############ DATABASE SEARCH PARAMETERS ############ +[search] + +mgf_dir: ${data.mgf_dir} +prep_path: ${data.prep_dir} +pep_dir: ${data.pep_dir} +out_pin_dir : ${data.out_pin_dir} + +model_name : ${MODEL_2} +specollate_model_path: ${MODEL} + + +# Batch sizes for forward pass through the network +spec_batch_size : ${data.spec_batch_size} +pep_batch_size : ${data.pep_batch_size} + +# Batch size for database search +search_spec_batch_size : ${data.search_spec_batch_size} + +precursor_tolerance : ${data.precursor_tolerance} # Precursor tolerance to use during database search (Da or ppm) +precursor_tolerance_type : ${data.precursor_tolerance_type} # either ppm or Da + +keep_psms : ${data.keep_psms} # Number of top scoring psms to keep + +# Number of modified peptides to be generated to search against. +# Different than the one in input section +num_mods : ${data.num_mods} + +charge: ${data.charge} # charge to be used during search + +############ FILTERING PARAMETERS ############ +[filter] +length_filter: True +len_tol_neg: -1 +len_tol_pos: 1 +missed_cleavages_filter: True +modification_filter: True + +############### OUT OF CORE PARAMETERS ############## +[ooc] +chunk_size: 10000000 + +############ MACHINE LEARNING PARAMETERS ############ +[ml] + +batch_size : 1024 + +test_size : 0.2 + +max_spec_len : 200 +min_pep_len: 7 +max_pep_len : 30 +# slightly larger than max_pep_len to account for modifications +pep_seq_len : 36 +max_clvs : 2 +embedding_dim : 1024 +encoder_layers : 4 +num_heads : 16 + +train_count : 0 + +ce_weight_clv : 1 +ce_weight_mod : 1 +mse_weight : 3 + +dropout : 0.3 + +lr : 0.0001 + +weight_decay : 0.0001 + +epochs : 5 + +margin : 0.2 + +read_split_listing : False + +############ DEFAULT VALUES ############ +# DO NOT CHANGE +[default] +msp_file : /data/human_consensus_final_true_lib.msp +mgf_files : /data/ +spec_size : 8000 +charge : 2 +use_mods : False +batch_size : 1024 + +` + await window.electron.ipcRenderer.invoke('write-file', CONFIG, config) +} diff --git a/electron-app/tsconfig.web.json b/electron-app/tsconfig.web.json index 9c16b66..610b6e6 100644 --- a/electron-app/tsconfig.web.json +++ b/electron-app/tsconfig.web.json @@ -4,7 +4,8 @@ "src/renderer/src/env.d.ts", "src/renderer/src/**/*", "src/renderer/src/**/*.tsx", - "src/preload/*.d.ts" + "src/preload/*.d.ts", + "types" ], "compilerOptions": { "composite": true, diff --git a/electron-app/types/electron-api.d.ts b/electron-app/types/electron-api.d.ts new file mode 100644 index 0000000..2001e69 --- /dev/null +++ b/electron-app/types/electron-api.d.ts @@ -0,0 +1,11 @@ +// electron-api.d.ts +import { ElectronAPI } from '@electron-toolkit/preload' + +declare module '@electron-toolkit/preload' { + interface ElectronAPI { + getEnvVariable: (key: string) => string | undefined + runCmd: any + onCmdOutput: any + terminateCmd: any + } +} diff --git a/installer.py b/installer.py index c7999a9..9919544 100644 --- a/installer.py +++ b/installer.py @@ -6,8 +6,10 @@ import requests import glob from zipfile import ZipFile +import argparse MODEL_URL = "https://github.com/pcdslab/ProteoRift/releases/download/V1.0.0/specollate_model_weights.pt" +MODEL_2_URL = "https://github.com/pcdslab/ProteoRift/releases/download/V1.0.0/proteorift_model_weights.pt" url = f'https://api.github.com/repos/pcdslab/MAESTRO/releases/latest' @@ -67,6 +69,7 @@ def main(): # Copy SpeCollate to electron-app electron_app_dir = Path(path) spe_collate_dest = Path(path) / "SpeCollate" + proteo_dest = Path(path) / "ProteoRift-main" app_name = "" if spe_collate_dest.exists(): @@ -78,6 +81,16 @@ def main(): run_command(f"cd *-MAESTRO* && cp -r SpeCollate {electron_app_dir}") run_command(f"rm -rf {file}") run_command(f"rm -rf *-MAESTRO*") + + if proteo_dest.exists(): + print("ProteoRift Exist") + else: + print("ProteoRift Doesn't Exist, Downloading") + file = download_file("https://github.com/pcdslab/ProteoRift/archive/refs/heads/main.zip", electron_app_dir) + extract_zip(file, electron_app_dir) + + print(file) + run_command(f"rm -rf {file}") if check_for_electron_app(): app_name = check_for_electron_app()[0] @@ -87,6 +100,7 @@ def main(): # Download the model file model_filepath = download_file(MODEL_URL, models_dir) + model_2_filepath = download_file(MODEL_2_URL, models_dir) # Install Python if not installed python_bin = python_dir / "bin/python3" @@ -115,7 +129,9 @@ def main(): with env_file.open("a") as f: f.write("{\n") f.write(f'"SPECOLLATE":"{python_bin} {spe_collate_dest}/run_search.py",\n') + f.write(f'"PROTEORIFT":"{python_bin} {proteo_dest}/run_search.py",\n') f.write(f'"MODEL":"{model_filepath}",\n') + f.write(f'"MODEL_2":"{model_2_filepath}",\n') f.write(f'"SPECOLLATE_CONFIG":"{Path(path)}/config.ini"\n') f.write("}") @@ -123,9 +139,22 @@ def main(): # Install npm dependencies and start the Electron app os.chdir(electron_app_dir) - - run_command(f"chmod +x {electron_app_dir}/{app_name}" ) - run_command(f"{electron_app_dir}/{app_name}") + + parser = argparse.ArgumentParser(description="Script with --dev flag") + parser.add_argument( + '--dev', + action='store_true', + help='Run the script in development mode' + ) + + args = parser.parse_args() + + if args.dev: + os.chdir(f"{electron_app_dir}/electron-app") + run_command(f"npm run dev" ) + else: + run_command(f"chmod +x {electron_app_dir}/{app_name}" ) + run_command(f"{electron_app_dir}/{app_name}") if __name__ == "__main__": main()