fix: 优化ReadBaseCtrlInfo方法

This commit is contained in:
orgin 2023-09-21 19:58:46 +08:00
parent 03954a4d2a
commit 7e1839ebc0

View File

@ -31,9 +31,7 @@ import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
@ -482,6 +480,110 @@ public class GammaFileUtil {
}
}
public void ReadBaseCtrlInfo(PHDFile phd, InputStream in){
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line ;
String block_name = null;
HashMap<String, List<Double>> map = new HashMap<>();
while (null != (line = reader.readLine())) {
if (line.contains("#")) {
block_name = line.trim();
map.put(block_name, new LinkedList<>());
continue;
}
List<Double> data = map.get(block_name);
String[] split = line.split("\\s+");
for(String str : split) {
if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){
double d = Double.parseDouble(str);
data.add(d);
} else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) {
data.add(0.0);
}
}
}
if(map.containsKey("#AnalyseRange")) {
List<Double> vTemp = map.get("#AnalyseRange");
if(vTemp.size() == 2) {
phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue());
phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue());
}
} else if(map.containsKey("#XCtrl")) {
List<Double> vTemp = map.get("#XCtrl");
phd.getBaseCtrls().setXCtrl(vTemp);
} else if(map.containsKey("#YCtrl")) {
List<Double> vTemp = map.get("#YCtrl");
phd.getBaseCtrls().setYCtrl(vTemp);
} else if(map.containsKey("#YSlope")) {
List<Double> vTemp = map.get("#YSlope");
phd.getBaseCtrls().setYSlope(vTemp);
} else if(map.containsKey("#Baseline")) {
List<Double> vTemp = map.get("#Baseline");
List<Double> list = vTemp.subList(1, vTemp.size());
phd.getBaseCtrls().setBaseline(list);
} else if(map.containsKey("#StepCounts")) {
List<Double> vTemp = map.get("#StepCounts");
List<Double> list = vTemp.subList(1, vTemp.size());
phd.getBaseCtrls().setStepCounts(list);
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void ReadBaseCtrlInfo(PHDFile phd, InputStream in){
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String line ;
String block_name = null;
HashMap<String, List<Double>> map = new HashMap<>();
while (null != (line = reader.readLine())) {
if (line.contains("#")) {
block_name = line.trim();
map.put(block_name, new LinkedList<>());
continue;
}
List<Double> data = map.get(block_name);
String[] split = line.split("\\s+");
for(String str : split) {
if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){
double d = Double.parseDouble(str);
data.add(d);
} else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) {
data.add(0.0);
}
}
}
if(map.containsKey("#AnalyseRange")) {
List<Double> vTemp = map.get("#AnalyseRange");
if(vTemp.size() == 2) {
phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue());
phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue());
}
} else if(map.containsKey("#XCtrl")) {
List<Double> vTemp = map.get("#XCtrl");
phd.getBaseCtrls().setXCtrl(vTemp);
} else if(map.containsKey("#YCtrl")) {
List<Double> vTemp = map.get("#YCtrl");
phd.getBaseCtrls().setYCtrl(vTemp);
} else if(map.containsKey("#YSlope")) {
List<Double> vTemp = map.get("#YSlope");
phd.getBaseCtrls().setYSlope(vTemp);
} else if(map.containsKey("#Baseline")) {
List<Double> vTemp = map.get("#Baseline");
List<Double> list = vTemp.subList(1, vTemp.size());
phd.getBaseCtrls().setBaseline(list);
} else if(map.containsKey("#StepCounts")) {
List<Double> vTemp = map.get("#StepCounts");
List<Double> list = vTemp.subList(1, vTemp.size());
phd.getBaseCtrls().setStepCounts(list);
}
} catch (IOException e) {
e.printStackTrace();
}
}
public boolean getResultFromDB(String dbName, String userName, Integer sampleId, PHDFile phd, Result result) {
//判断连接的数据库
String T_analy, T_calib, T_peaks, T_param, T_nuc_line, T_nuc_act, T_qc, T_setting;