- Define project root and output directory.
- Specify input, database, adducts, and results file paths.
- Verify existence of input, database, and adducts files.
- Load input, database, and adducts files using `pd.read_csv`.
- Strip whitespace from column names.
- Rename specific columns for consistency.
- Remove duplicated columns.
5. Build required DB columns**
- Ensure required columns exist and are correctly formatted.
- Assign IDs based on available columns.
- Handle missing columns with default values.
6. Validate DB formulas**
- Define `is_valid_formula` function to check formula validity.
- Apply validation and remove invalid entries.
- Define required adduct columns.
- Raise error if columns are missing.
- Clean and format adduct data.
- Reset indices for DB, adductsAll, and df_ipa.
- Execute `ipa.simpleIPA` with specified parameters.
- Note: This may take a few minutes for 1000 features.
- Handle both dict and dataframe outputs.
- Convert dict result to dataframe if necessary.
- Insert feature_id into annotations.
- Concatenate rows into final dataframe.
- Save final dataframe to CSV.
- Print top annotations or first 20 rows if no 'post' column.
- Check if annotations are a DataFrame or dict.
- Insert feature_id and append to rows.
- Concatenate rows into final_df.
- Save final_df to CSV and print top annotations.