You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

修改UNIDEC中AgilentImporter路径后出现BaseTof.dll依赖错误求助

修改UNIDEC中AgilentImporter路径后出现BaseTof.dll依赖错误求助

我最近在研究UNIDEC软件里把Agilent .d文件夹转成txt文件的代码,于是打开了AgilentImporter.py修改了目标文件路径,结果运行时弹出了BaseTof.dll找不到的错误——明明这个文件已经存在,我重新下载替换后还是不行,实在搞不懂哪里出问题了。

我运行的代码:

from copy import deepcopy
import numpy as np
from unidec.UniDecImporter.Agilent.MZFILE import MZFile as mzFile
from unidec.UniDecImporter.Importer import *
from unidec import tools as ud
from unidec.UniDecImporter.ImportTools import merge_spectra

# When is the msrun scaninfo even being populated ever


class AgilentImporter(Importer):
    """
    Imports Agilent data files.

    Note: Agilent scans are 0 indexed, so the first scan is scan 0, not scan 1.
    """
    def __init__(self, path, **kwargs):
        super().__init__(path, **kwargs)
        print("Reading Agilent Data:", path)
        self.msrun = mzFile(path)
        self.init_scans()

        self.cdms_support = False
        self.imms_support = False
        self.chrom_support = True

    def init_scans(self):
        self.times = []
        self.scans = []

        curr_info = self.msrun.scan_info()
        for i in curr_info:
            self.scans.append(i[2]+1)
            self.times.append(i[0])

        self.times = np.array(self.times)
        self.scans = np.array(self.scans)
        self.scan_range = [np.amin(self.scans), np.amax(self.scans)]

    def get_all_scans(self):
        self.data = []
        for s in self.scans:
            impdat = np.array(self.msrun.scan(int(s)-1))
            try:
                impdat = impdat[impdat[:, 0] > 10]
            except Exception as e:
                print("Error Importing Data, Scan:", s, "Data:", impdat, "Error:", e)
            self.data.append(impdat)
        return self.data


    def get_single_scan(self, scan, threshold=-1):
        try:
            impdat = np.array(self.msrun.scan(int(scan)-1))
            impdat = np.transpose([impdat[:, 0], impdat[:, 1]])
            impdat = impdat[impdat[:, 0] > 10]
            if threshold >= 0:
                impdat = impdat[impdat[:, 1] > threshold]
            return impdat
        except Exception as e:
            print(f"Error in get_single_scan for scan {scan}: {e}")
            return None


    def get_avg_scan(self, scan_range=None, time_range=None, mzbins=None):
        """
        Returns merged 1D MS data from mzML import
        :return: merged data
        """
        scan_range = self.scan_range_from_inputs(scan_range, time_range)

        self.datascans = []
        for s in self.scans:
            self.datascans.append(self.msrun.scan(int(s-1)))

        if scan_range[1] - scan_range[0] > 1:
            # noinspection PyUnresolvedReferences
            data = np.array(list(self.msrun.average_scan(list(np.array(scan_range)-1), self.datascans)))
        else:
            impdat = np.array(self.msrun.scan(int(scan_range[0]-1)))
            impdat = impdat[impdat[:, 0] > 10]
            data = impdat

        return data

    # noinspection PyArgumentList
    def get_tic(self):
        try:
            xic = self.msrun.xic(filter="Full")
        except:
            xic = self.msrun.xic()
        return xic


    def get_polarity(self, scan=1):
        self.scan_info = self.msrun.scan_info()
        line = self.scan_info[scan]
        # previous checking for +
        if "Positive" in line:
            print("Polarity: Positive")
            return "Positive"
        # previous checking for -
        if "Negative" in line:
            print("Polarity: Negative")
            return "Negative"
        print("Polarity: Unknown")
        return None

    def get_ms_order(self, scan=1):
        scan_info = self.msrun.scan_info()
        for line in scan_info:
            if scan == int(line[2]):
                if "MS1" in line:
                    return 1
                elif "MS2" in line:
                    return 2
        print("MS Order: Unknown")
        return 1

    def close(self):
        self.msrun.close()


if __name__ == '__main__':
    import time
    # path = "Z:\\Group Share\\JGP\\DiverseDataExamples\\AgilentData\\2019_05_15_bsa_ccs_02.d"
    path = "C:\\Users\\suneel\\Desktop\\converter\\4deg_T_17082023.d"
    #path = "C:\\Data\\DataTypeCollection\\test_agilent.d"
    d = AgilentImporter(path)
    print(d.get_all_scans())

报错信息:

Reading Agilent Data: C:\Users\suneel\Desktop\converter\4deg_T_17082023.d
Traceback (most recent call last):
  File "c:\Users\suneel\Downloads\UniDec-v.8.0.0\UniDec-v.8.0.0\unidec\UniDecImporter\Agilent\AgilentImporter.py", line 129, in <module>
    d = AgilentImporter(path)
  File "c:\Users\suneel\Downloads\UniDec-v.8.0.0\UniDec-v.8.0.0\unidec\UniDecImporter\Agilent\AgilentImporter.py", line 20, in __init__
    self.msrun = mzFile(path)
  File "C:\Users\suneel\AppData\Local\Programs\Python\Python310\lib\site-packages\unidec\UniDecImporter\Agilent\MZFILE.py", line 57, in __init__
    self.source = MassSpecDataReader()
System.IO.FileNotFoundException: Could not load file or assembly 'BaseTof.dll' or one of its dependencies.

我试过的操作:

  • 确认BaseTof.dll文件存在于对应的目录中
  • 重新下载该DLL文件替换原文件

有没有大佬遇到过类似的问题?麻烦给点解决思路,谢谢!


备注:内容来源于stack exchange,提问作者Hulkbuster

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 13:35:30