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

2024-04-28 16:38

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

实际进行生信分析时,更需要的是series类型的数据,和Java 将PubMed GEO DataSets中dataset类型的检索结果转化为Excel中的方法一样,首先转成TXT,然后借助jxl包转为Excel。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
源代码如下:

/** 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 Series {/*** @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\\series.txt");File out = new File("C:\\Users\\Lenovo\\Desktop\\Series.xls");WritableWorkbook wwb = Workbook.createWorkbook(out);WritableSheet series = wwb.createSheet("Series", 0);series.setColumnView(0, 5);series.setColumnView(1, 40);series.setColumnView(2, 40);series.setColumnView(4, 20);series.setColumnView(6, 20);series.setColumnView(10, 12);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, "Dataset"));series.addCell(new Label(6, 0, "Platform(s)"));series.addCell(new Label(7, 0, "Sample"));series.addCell(new Label(8, 0, "FTP download"));series.addCell(new Label(9, 0, "SRA Run Selector"));series.addCell(new Label(10, 0, "Accession"));series.addCell(new Label(11, 0, "ID"));series.addCell(new Label(12, 0, "Project"));BufferedReader reader = null;String tempString = null;int number = 1;int index0, index1, index2, index3, index4, index5, index6;try {reader = new BufferedReader(new FileReader(in));for (int n = 1; n <= 347; n++) {tempString = reader.readLine();tempString = reader.readLine();series.addCell(new Label(0, number, String.valueOf(number)));series.addCell(new Label(1, number, tempString.substring(tempString.indexOf(".") + 2)));tempString = reader.readLine();series.addCell(new Label(2, number, tempString));tempString = reader.readLine();index0 = tempString.indexOf("Project:");if(index0!=-1){series.addCell(new Label(12, number, tempString.substring(10)));tempString = reader.readLine();}else series.addCell(new Label(3, number, tempString.substring(10)));tempString = reader.readLine();series.addCell(new Label(4, number, tempString.substring(6)));tempString = reader.readLine();index1 = tempString.indexOf("Dataset");index2 = tempString.indexOf(":");index3 = tempString.indexOf("Sample");index4 = tempString.indexOf("related");series.addCell(new Label(5, number, "—"));if (index1 != -1) {series.addCell(new Label(5, number, tempString.substring(index1 + 9, index1 + 16).trim()));}if (tempString.substring(index3 - 4, index3 - 2).contains(" ")) {series.addCell(new Label(7, number, tempString.substring(index3 - 3, index3 - 1).trim()));series.addCell(new Label(6, number, tempString.substring(index2 + 2, index3 - 3).trim()));} else {series.addCell(new Label(7, number, tempString.substring(index3 - 5, index3 - 1).trim()));series.addCell(new Label(6, number, tempString.substring(index2 + 2, index3 - 5).trim()));}if (index4 != -1) {series.addCell(new Label(6, number, tempString.substring(0, index2 + 9).trim()));}tempString = reader.readLine();series.addCell(new Label(8, number, tempString.substring(14)));tempString = reader.readLine();index5 = tempString.indexOf("SRA");if (index5 != -1) {series.addCell(new Label(9, number, tempString.substring(18)));tempString = reader.readLine();}index6 = tempString.indexOf("ID");series.addCell(new Label(10, number, tempString.substring(19, index6 - 1)));series.addCell(new Label(11, number, tempString.substring(index6 + 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中series类型的检索结果转化为Excel的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

Spring Boot集成/输出/日志级别控制/持久化开发实践

《SpringBoot集成/输出/日志级别控制/持久化开发实践》SpringBoot默认集成Logback,支持灵活日志级别配置(INFO/DEBUG等),输出包含时间戳、级别、类名等信息,并可通过... 目录一、日志概述1.1、Spring Boot日志简介1.2、日志框架与默认配置1.3、日志的核心作用

破茧 JDBC:MyBatis 在 Spring Boot 中的轻量实践指南

《破茧JDBC:MyBatis在SpringBoot中的轻量实践指南》MyBatis是持久层框架,简化JDBC开发,通过接口+XML/注解实现数据访问,动态代理生成实现类,支持增删改查及参数... 目录一、什么是 MyBATis二、 MyBatis 入门2.1、创建项目2.2、配置数据库连接字符串2.3、入

Springboot项目启动失败提示找不到dao类的解决

《Springboot项目启动失败提示找不到dao类的解决》SpringBoot启动失败,因ProductServiceImpl未正确注入ProductDao,原因:Dao未注册为Bean,解决:在启... 目录错误描述原因解决方法总结***************************APPLICA编

深度解析Spring Security 中的 SecurityFilterChain核心功能

《深度解析SpringSecurity中的SecurityFilterChain核心功能》SecurityFilterChain通过组件化配置、类型安全路径匹配、多链协同三大特性,重构了Spri... 目录Spring Security 中的SecurityFilterChain深度解析一、Security

SpringBoot多环境配置数据读取方式

《SpringBoot多环境配置数据读取方式》SpringBoot通过环境隔离机制,支持properties/yaml/yml多格式配置,结合@Value、Environment和@Configura... 目录一、多环境配置的核心思路二、3种配置文件格式详解2.1 properties格式(传统格式)1.

Apache Ignite 与 Spring Boot 集成详细指南

《ApacheIgnite与SpringBoot集成详细指南》ApacheIgnite官方指南详解如何通过SpringBootStarter扩展实现自动配置,支持厚/轻客户端模式,简化Ign... 目录 一、背景:为什么需要这个集成? 二、两种集成方式(对应两种客户端模型) 三、方式一:自动配置 Thick

Spring WebClient从入门到精通

《SpringWebClient从入门到精通》本文详解SpringWebClient非阻塞响应式特性及优势,涵盖核心API、实战应用与性能优化,对比RestTemplate,为微服务通信提供高效解决... 目录一、WebClient 概述1.1 为什么选择 WebClient?1.2 WebClient 与

Java.lang.InterruptedException被中止异常的原因及解决方案

《Java.lang.InterruptedException被中止异常的原因及解决方案》Java.lang.InterruptedException是线程被中断时抛出的异常,用于协作停止执行,常见于... 目录报错问题报错原因解决方法Java.lang.InterruptedException 是 Jav

Python进行JSON和Excel文件转换处理指南

《Python进行JSON和Excel文件转换处理指南》在数据交换与系统集成中,JSON与Excel是两种极为常见的数据格式,本文将介绍如何使用Python实现将JSON转换为格式化的Excel文件,... 目录将 jsON 导入为格式化 Excel将 Excel 导出为结构化 JSON处理嵌套 JSON:

深入浅出SpringBoot WebSocket构建实时应用全面指南

《深入浅出SpringBootWebSocket构建实时应用全面指南》WebSocket是一种在单个TCP连接上进行全双工通信的协议,这篇文章主要为大家详细介绍了SpringBoot如何集成WebS... 目录前言为什么需要 WebSocketWebSocket 是什么Spring Boot 如何简化 We