Java 将PubMed GEO DataSets中dataset类型的检索结果转化为Excel

2024-04-28 16:38

本文主要是介绍Java 将PubMed GEO DataSets中dataset类型的检索结果转化为Excel,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

检索结果举例
为进行生信分析,需要对检索结果转化为Excel并且以标签作为列。首先将检索结果Send to File转化成TXT格式,如下:
在这里插入图片描述
在这里插入图片描述
通过下面的程序进一步转为Excel(使用jxl包):
在这里插入图片描述
源代码:

/** To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/
package ncbi;import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;/**** @author wgyklh*/
public class NCBI {/*** @param args the command line arguments* @throws java.lang.Exception*/public static void main(String[] args) throws Exception {// TODO code application logic hereFile in = new File("C:\\Users\\Lenovo\\Desktop\\gds_result.txt");File out = new File("C:\\Users\\Lenovo\\Desktop\\gds.result.xls");WritableWorkbook wwb = Workbook.createWorkbook(out);WritableSheet dataset = wwb.createSheet("DataSet", 0);WritableSheet series = wwb.createSheet("Series", 1);WritableSheet platform= wwb.createSheet("Platform", 2);WritableSheet sample= wwb.createSheet("Sample", 3);dataset.addCell(new Label(0, 0, "Number"));dataset.addCell(new Label(1, 0, "Title"));dataset.addCell(new Label(2, 0, "Introduction"));dataset.addCell(new Label(3, 0, "Organism"));dataset.addCell(new Label(4, 0, "Type"));dataset.addCell(new Label(5, 0, "Platform"));dataset.addCell(new Label(6, 0, "Series"));dataset.addCell(new Label(7, 0, "Sample"));dataset.addCell(new Label(8, 0, "FTP download"));dataset.addCell(new Label(9, 0, "Accession"));dataset.addCell(new Label(10, 0, "ID"));series.addCell(new Label(0, 0, "Number"));series.addCell(new Label(1, 0, "Title"));series.addCell(new Label(2, 0, "Introduction"));series.addCell(new Label(3, 0, "Organism"));series.addCell(new Label(4, 0, "Type"));series.addCell(new Label(5, 0, "Platform"));series.addCell(new Label(6, 0, "Sample"));series.addCell(new Label(7, 0, "FTP download"));series.addCell(new Label(8, 0, "Accession"));series.addCell(new Label(9, 0, "ID"));BufferedReader reader = null;String tempString = null;int number = 1;int index1 = 0;int index2 = 0;int index3 = 0;try {reader = new BufferedReader(new FileReader(in));for (int n = 1; n <= 32; n++) {tempString = reader.readLine();tempString = reader.readLine();System.out.println(tempString);dataset.addCell(new Label(0, number, String.valueOf(number)));dataset.addCell(new Label(1, number, tempString.substring(3)));tempString = reader.readLine();dataset.addCell(new Label(2, number, tempString));tempString = reader.readLine();dataset.addCell(new Label(3, number, tempString.substring(10)));tempString = reader.readLine();dataset.addCell(new Label(4, number, tempString.substring(6)));tempString = reader.readLine();index1 = tempString.indexOf("Series");index2 = tempString.indexOf("Sample");System.out.println(index1 + "   " + index2);dataset.addCell(new Label(5, number, tempString.substring(10, index1 - 1)));dataset.addCell(new Label(6, number, tempString.substring(index1 + 8, index1 + 16)));dataset.addCell(new Label(7, number, tempString.substring(index1 + 16, index2 - 1).trim()));tempString = reader.readLine();dataset.addCell(new Label(8, number, tempString.substring(14)));tempString = reader.readLine();index3 = tempString.indexOf("ID");dataset.addCell(new Label(9, number, tempString.substring(20, 27)));dataset.addCell(new Label(10, number, tempString.substring(index3 + 4)));number++;}reader.close();wwb.write();wwb.close();} catch (FileNotFoundException e) {} catch (IOException e) {} finally {if (reader != null) {try {reader.close();} catch (IOException e) {}}}}
}

这篇关于Java 将PubMed GEO DataSets中dataset类型的检索结果转化为Excel的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/943734

相关文章

Java中ArrayList和LinkedList有什么区别举例详解

《Java中ArrayList和LinkedList有什么区别举例详解》:本文主要介绍Java中ArrayList和LinkedList区别的相关资料,包括数据结构特性、核心操作性能、内存与GC影... 目录一、底层数据结构二、核心操作性能对比三、内存与 GC 影响四、扩容机制五、线程安全与并发方案六、工程

JavaScript中的reduce方法执行过程、使用场景及进阶用法

《JavaScript中的reduce方法执行过程、使用场景及进阶用法》:本文主要介绍JavaScript中的reduce方法执行过程、使用场景及进阶用法的相关资料,reduce是JavaScri... 目录1. 什么是reduce2. reduce语法2.1 语法2.2 参数说明3. reduce执行过程

如何使用Java实现请求deepseek

《如何使用Java实现请求deepseek》这篇文章主要为大家详细介绍了如何使用Java实现请求deepseek功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1.deepseek的api创建2.Java实现请求deepseek2.1 pom文件2.2 json转化文件2.2

Java调用DeepSeek API的最佳实践及详细代码示例

《Java调用DeepSeekAPI的最佳实践及详细代码示例》:本文主要介绍如何使用Java调用DeepSeekAPI,包括获取API密钥、添加HTTP客户端依赖、创建HTTP请求、处理响应、... 目录1. 获取API密钥2. 添加HTTP客户端依赖3. 创建HTTP请求4. 处理响应5. 错误处理6.

Spring AI集成DeepSeek的详细步骤

《SpringAI集成DeepSeek的详细步骤》DeepSeek作为一款卓越的国产AI模型,越来越多的公司考虑在自己的应用中集成,对于Java应用来说,我们可以借助SpringAI集成DeepSe... 目录DeepSeek 介绍Spring AI 是什么?1、环境准备2、构建项目2.1、pom依赖2.2

Spring Cloud LoadBalancer 负载均衡详解

《SpringCloudLoadBalancer负载均衡详解》本文介绍了如何在SpringCloud中使用SpringCloudLoadBalancer实现客户端负载均衡,并详细讲解了轮询策略和... 目录1. 在 idea 上运行多个服务2. 问题引入3. 负载均衡4. Spring Cloud Load

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

在 Spring Boot 中使用 @Autowired和 @Bean注解的示例详解

《在SpringBoot中使用@Autowired和@Bean注解的示例详解》本文通过一个示例演示了如何在SpringBoot中使用@Autowired和@Bean注解进行依赖注入和Bean... 目录在 Spring Boot 中使用 @Autowired 和 @Bean 注解示例背景1. 定义 Stud

如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别详解

《如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别详解》:本文主要介绍如何通过海康威视设备网络SDK进行Java二次开发摄像头车牌识别的相关资料,描述了如何使用海康威视设备网络SD... 目录前言开发流程问题和解决方案dll库加载不到的问题老旧版本sdk不兼容的问题关键实现流程总结前言作为

Python如何计算两个不同类型列表的相似度

《Python如何计算两个不同类型列表的相似度》在编程中,经常需要比较两个列表的相似度,尤其是当这两个列表包含不同类型的元素时,下面小编就来讲讲如何使用Python计算两个不同类型列表的相似度吧... 目录摘要引言数字类型相似度欧几里得距离曼哈顿距离字符串类型相似度Levenshtein距离Jaccard相