Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

4 watching

Forks

Latest commit

Β 

History

53 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Memory-Based AI Agents Integrated with Real-Time Quality Control Automates Chip-based nanoESI-MS/MS Platform


🎯 Overview

This repository implements the first LLM-driven AI agent framework for chip-based nanoESI-MS/MS automation, specifically designed for TriVersa NanoMate coupled to SCIEX 4000 QTRAP systems. The framework leverages large language models to interpret natural language instructions and autonomously execute analytical workflowsβ€”from worklist generation and real-time quality control to data conversion, visualization, and literature retrievalβ€”without requiring programming expertise. Unlike traditional vendor software or custom scripts, the system integrates persistent memory to preserve both lab-specific protocols and published knowledge, while maintaining a modular, instrument-agnostic architecture that can evolve as experimental needs change across diverse analytical platforms beyond mass spectrometry.


✨ Key Features

πŸ€– AI-Powered Agents

  • QC Agent - Automated real-time quality control
  • Worklist Agent - Intelligent sample worklist generation
  • Parse Agent - Automated data extraction and organization
  • Visualization Agent - Automated data visualization
  • Helper Agent - Retrival Augmented Generation (RAG) for scientific literature and persistent memory for knowledge retention

πŸš€ Quick Start

1. Environment Setup

# Create conda environment
conda create --name qtrap_paper --clone sciborg_dev
# Or create from scratch:
conda env create -f docs/environment/environment.yml

# Activate environment
conda activate qtrap_paper

# Install additional dependencies
pip install python-dotenv  # For secure API key loading

2. Configure API Keys (Secure Method)

# Create .env file for Helper Agent
cd helper_agent
cp .env.example .env
nano .env  # Add your OPENAI_API_KEY

See helper_agent/API_KEY_SETUP.md for detailed security setup.

3. Using Helper Agent (Standalone)

import sys
sys.path.insert(0, "helper_agent/drivers")

from config_loader import setup_environment
from qtrap_utils import setup_helper, ask_agent, tell_agent

# Load API key securely
setup_environment()

# Setup agent
helper = setup_helper(model="gpt-4o", temperature=0)

# Ask questions (searches literature)
answer = ask_agent("What solvent for lipidomics?")

# Store your experimental findings
tell_agent("Project SolventMatrix: 2:1 MeOH/ACN is best...")

# Ask again (now uses YOUR data!)
answer = ask_agent("What solvent for lipidomics?")

4. Using LangGraph Agents (Optional)

# Install LangGraph
cd UI_qtrap/react-agent
pip install -e .

# Configure .env
cp .env.example .env
# Add: OPENAI_API_KEY, TAVILY_API_KEY

# Start LangGraph UI
langgraph dev

Open browser to http://localhost:8123 to access LangGraph Studio.


πŸ“ Repository Structure

Chip-based-nanoESI-MS-MS-AI-Agents/
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ .gitignore                   # Git configuration
β”‚
β”œβ”€β”€ UI_qtrap/                    # Main QTRAP workflow
β”‚   └── react-agent/            # LangGraph agents
β”‚       β”œβ”€β”€ src/react_agent/    # Core scripts
β”‚       β”‚   β”œβ”€β”€ Q_QC.py         # QC analysis (main)
β”‚       β”‚   β”œβ”€β”€ Q_worklist.py   # Worklist generation
β”‚       β”‚   β”œβ”€β”€ Q_parse.py      # Data parsing
β”‚       β”‚   β”œβ”€β”€ Q_helper.py     # RAG helper
β”‚       β”‚   └── Q_viz_*.py      # Visualization scripts
β”‚       └── langgraph.json      # Agent configuration
β”‚
β”œβ”€β”€ helper_agent/                # πŸ†• Standalone Helper AI Agent
β”‚   β”œβ”€β”€ drivers/                # Core modules
β”‚   β”‚   β”œβ”€β”€ qtrap_utils.py      # Main API (use this!)
β”‚   β”‚   β”œβ”€β”€ helper_agent_core.py # Agent implementation
β”‚   β”‚   β”œβ”€β”€ config_loader.py    # Secure API key loading
β”‚   β”‚   β”œβ”€β”€ archive/            # Old/unused files
β”‚   β”‚   └── README.md           # Module documentation
β”‚   β”‚
β”‚   β”œβ”€β”€ logs/                   # Organized log files
β”‚   β”‚   β”œβ”€β”€ ask_agent/          # Memory-first queries
β”‚   β”‚   β”œβ”€β”€ tell_agent/         # Memory storage
β”‚   β”‚   β”œβ”€β”€ query/              # Full RAG queries
β”‚   β”‚   └── README.md           # Log documentation
β”‚   β”‚
β”‚   β”œβ”€β”€ papers/                 # Scientific literature corpus
β”‚   β”‚   └── recentlipids7/      # Lipidomics papers
β”‚   β”‚       └── faiss_index/    # Vector embeddings
β”‚   β”‚
β”‚   β”œβ”€β”€ helper_agent_notebooks/ # Example notebooks
β”‚   β”œβ”€β”€ .env                    # API keys (gitignored)
β”‚   β”œβ”€β”€ .env.example            # API key template
β”‚   β”œβ”€β”€ API_KEY_SETUP.md        # Security guide
β”‚   └── ORGANIZATION_SUMMARY.md # Complete organization guide
β”‚
└── docs/                        # Documentation
    β”œβ”€β”€ README.md               # Documentation index
    β”œβ”€β”€ environment/            # Setup files
    β”œβ”€β”€ guides/                 # User guides
    β”œβ”€β”€ CLEANUP_SUMMARY.md      # Repo maintenance
    └── GIT_LARGE_FILES_REPORT.md

πŸ€– LangGraph Agents

agent_QC - Quality Control

  • Monitors MS data quality in real-time
  • Detects failed samples automatically
  • Generates TIC plots and QC metrics
  • Triggers reprocessing workflows

agent_worklist - Worklist Generation

  • Creates worklists formatted for Analyst v1.6.3
  • Formats for windows 7 and moves files to QTRAP worklist directory automatically
  • Operator initials for each experiemnt

agent_parse - Data Parsing

  • Extracts data from raw .wiff files
  • Converts to structured CSV format
  • Organizes by project

agent_helper - Literature Assistant

  • RAG-based Q&A on scientific papers
  • Persistent memory for knowledge retention
  • Memory-first queries (checks stored data before searching literature)
  • Automatic logging of all interactions
  • Secure API key management

πŸ“š Documentation

User Guides


πŸ”§ Core Scripts

Quality Control

  • Q_QC.py - Main QC workflow with monitoring
  • Q_QC_TIC.py - TIC extraction and plotting
  • Q_viz_QC.py - QC visualization

Data Processing

  • Q_parse.py - Data parsing and extraction
  • Q_worklist.py - Worklist generation
  • Q_convert.py - MSConvert integration

Visualization

  • Q_viz_intensity.py - Intensity visualization
  • Q_viz_intensity_advanced.py - Advanced plots
  • Q_viz_intensity_advanced_part2.py - Statistical plots

AI Helper

  • Q_helper.py - RAG-based literature assistant (LangGraph integration)
  • helper_agent/ - Standalone Helper AI Agent system:
    • qtrap_utils.py - Main API for agent operations
    • helper_agent_core.py - Core RAG and memory implementation
    • config_loader.py - Secure API key management
    • Organized logging system (ask/tell/query logs)
    • Example notebooks with Project SolventMatrix demo

πŸ“Š Key Dependencies

Core AI Framework

  • LangGraph - Agent orchestration and workflow management
  • LangChain - LLM integration and tool calling
  • OpenAI GPT-4o - Language model for agent reasoning
  • FAISS - Vector database for RAG and literature search

Data Processing

  • Pandas - Data manipulation and analysis
  • NumPy/SciPy - Statistical analysis
  • python-dotenv - Secure environment variable management

Visualization

  • Matplotlib/Seaborn - Scientific visualization

πŸŽ“ Citation

If you use this workflow in your research, please cite:

Memory-Based AI Agents Integrated with Real-Time Quality Control Automates Chip-based nanoESI-MS/MS Platform
(In Preparation)

πŸ“§ Contact

For questions or collaboration:


🌟 Acknowledgments

This project uses:

  • LangGraph by LangChain
  • OpenAI API
  • Scientific Python ecosystem

Last Updated: October 22, 2025

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages