gpt4 book ai didi

java - FASTQC 在命令行上运行,但不在 python 子进程中运行(Java 异常(exception))

转载 作者:太空宇宙 更新时间:2023-11-04 10:25:53 25 4
gpt4 key购买 nike

我使用的命令行工具在从 Linux 命令行调用时工作正常,但在通过 Python subprocess 模块调用它时出现异常。我看过之前与此相关的帖子,但没有一个说明它如何在命令行上工作,但没有在 Python 中工作。

这是我得到的回溯示例:

Exception in thread "Thread-1" java.lang.Error: Probable fatal error:No fonts found.
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1236)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1100)
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:1037)
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:1054)
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2256)
at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1220)
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:1106)
at sun.font.CompositeFont.doDeferredInitialisation(CompositeFont.java:263)
at sun.font.CompositeFont.getSlotFont(CompositeFont.java:352)
at sun.font.CompositeStrike.getStrikeForSlot(CompositeStrike.java:78)
at sun.font.CompositeStrike.getFontMetrics(CompositeStrike.java:93)
at sun.font.FontDesignMetrics.initMatrixAndMetrics(FontDesignMetrics.java:359)
at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:350)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:302)
at sun.java2d.SunGraphics2D.getFontMetrics(SunGraphics2D.java:855)
at uk.ac.babraham.FastQC.Graphs.QualityBoxPlot.paint(QualityBoxPlot.java:88)
at javax.swing.JComponent.print(JComponent.java:1202)
at uk.ac.babraham.FastQC.Modules.AbstractQCModule.writeDefaultImage(AbstractQCModule.java:68)
at uk.ac.babraham.FastQC.Modules.PerBaseQualityScores.makeReport(PerBaseQualityScores.java:199)
at uk.ac.babraham.FastQC.Report.HTMLReportArchive.<init>(HTMLReportArchive.java:131)
at uk.ac.babraham.FastQC.Analysis.OfflineRunner.analysisComplete(OfflineRunner.java:178)
at uk.ac.babraham.FastQC.Analysis.AnalysisRunner.run(AnalysisRunner.java:110)
at java.lang.Thread.run(Thread.java:745)

我这样调用该工具:

def runCommand(self, command, directory):
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=directory)
out,err = process.communicate()

if out:
self.logger.info("Standard output: \n" + out.decode('utf-8') + "\n")
if err:
self.logger.info("Standard error: \n" + err.decode('utf-8') + "\n")

命令与我在命令行上运行它时使用的命令相同。

我检查以确保从命令行调用的 java 版本与使用 subprocess 调用的版本相同。可能是在subprocess中运行时环境被修改了,但是如何确保java中使用了字体包?

最佳答案

这是我用来从 python 运行 fastqc 的代码。它使用 subprocess.check_call 而不是 Popen。

def run(fastq_path, output_dir, options=['--extract',]):
"""
Run the fastqc program on a specified fastq file and return the output directory path.

Parameters
----------
fastq_path : str
Path to the fastq file to analyze.
output_dir : str
Directory where output will be written. It will be created if it does not exist.
options : list of str (optional)
Command-line flags and options to fastqc. Default is --extract.

Returns
-------
output_dir : str
The path to the directory containing the detailed output for this fastq file.
It will be a subdirectory of the specified output dir.
"""
utils.mkdir_p(output_dir)

command = "fastqc {} -o {} {}".format(' '.join(options), output_dir, fastq_path)
subprocess.check_call(command, shell=True)

# Fastqc creates a directory derived from the basename
fastq_dir = os.path.basename(fastq_path)
if fastq_dir.endswith(".gz"):
fastq_dir = fastq_dir[0:-3]
if fastq_dir.endswith(".fq"):
fastq_dir = fastq_dir[0:-3]
if fastq_dir.endswith(".fastq"):
fastq_dir = fastq_dir[0:-6]
fastq_dir = fastq_dir + "_fastqc"

# Delete the zip file and keep the uncompressed directory
zip_file = os.path.join(output_dir, fastq_dir + ".zip")
os.remove(zip_file)

output_dir = os.path.join(output_dir, fastq_dir)
return output_dir

关于java - FASTQC 在命令行上运行,但不在 python 子进程中运行(Java 异常(exception)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50535533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com