区块链技术博客
www.b2bchain.cn

FASTQC在命令行上运行,但不在python子进程中运行(Java异常) – java程序员分享

本文介绍了FASTQC在命令行上运行,但不在python子进程中运行(Java异常) – java程序员分享,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

从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调用的Java版本相同。可能是在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 

我正在将信息写入文本文件,如何更改正在写入文本文件的数据的字体大小。以及如何设置以粗体或下划线书写的数据。 参考方案 实际上,.txt格式不包含字体大小,键,斜体等格式。您可能想要使用markup language(例如html)或其他文件格式,例如rtf,pdf或其他名称。以下是有关学习html的一些信息:w3schools.com还有一个用于编写rtf的…

试图绕过Java并发问题,并且很难理解线程池,线程以及它们正在执行的可运行“任务”之间的关系。如果我创建一个有10个线程的线程池,那么我是否必须将相同的任务传递给池中的每个线程,或者池化的线程实际上只是与任务无关的“工人无人机”可用于执行任何任务?无论哪种方式,Executor / ExecutorService如何将正确的任务分配给正确的线程? 参考方案 …

java字节代码(已编译的语言,也称为目标代码)与机器代码(当前计算机的本机代码)之间有什么区别?我读过一些书,他们将字节码称为二进制指令,但我不知道为什么。 参考方案 字节码是独立于平台的,在Windows中运行的编译器编译的字节码仍将在linux / unix / mac中运行。机器代码是特定于平台的,如果在Windows x86中编译,则它将仅在Win…

有哪些替代继承的方法? java大神给出的解决方案 有效的Java:偏重于继承而不是继承。 (这实际上也来自“四人帮”)。他提出的理由是,如果扩展类未明确设计为继承,则继承会引起很多不正常的副作用。例如,对super.someMethod()的任何调用都可以引导您通过未知代码的意外路径。取而代之的是,持有对本来应该扩展的类的引用,然后委托给它。这是与Eric…

我想将BigInteger写入文件。做这个的最好方式是什么。当然,我想从输入流中读取(使用程序,而不是人工)。我必须使用ObjectOutputStream还是有更好的方法?目的是使用尽可能少的字节。谢谢马丁 参考方案 Java序列化(ObjectOutputStream / ObjectInputStream)是将对象序列化为八位字节序列的一种通用方法。但…

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » FASTQC在命令行上运行,但不在python子进程中运行(Java异常) – java程序员分享
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们