2828 |
16 Oct 14 |
nicklas |
1 |
package net.sf.basedb.reggie.dao; |
2828 |
16 Oct 14 |
nicklas |
2 |
|
4538 |
22 Jun 17 |
nicklas |
3 |
import java.io.IOException; |
4538 |
22 Jun 17 |
nicklas |
4 |
import java.io.InputStream; |
2828 |
16 Oct 14 |
nicklas |
5 |
import java.util.ArrayList; |
2828 |
16 Oct 14 |
nicklas |
6 |
import java.util.Collection; |
2863 |
28 Oct 14 |
nicklas |
7 |
import java.util.HashMap; |
2828 |
16 Oct 14 |
nicklas |
8 |
import java.util.List; |
2863 |
28 Oct 14 |
nicklas |
9 |
import java.util.Map; |
4538 |
22 Jun 17 |
nicklas |
10 |
import java.util.regex.Pattern; |
2828 |
16 Oct 14 |
nicklas |
11 |
|
2828 |
16 Oct 14 |
nicklas |
12 |
import org.json.simple.JSONObject; |
2828 |
16 Oct 14 |
nicklas |
13 |
|
2863 |
28 Oct 14 |
nicklas |
14 |
import net.sf.basedb.core.BaseException; |
2828 |
16 Oct 14 |
nicklas |
15 |
import net.sf.basedb.core.DbControl; |
3531 |
05 Oct 15 |
nicklas |
16 |
import net.sf.basedb.core.File; |
3531 |
05 Oct 15 |
nicklas |
17 |
import net.sf.basedb.core.FileSetMember; |
4545 |
28 Jun 17 |
nicklas |
18 |
import net.sf.basedb.core.InvalidDataException; |
4538 |
22 Jun 17 |
nicklas |
19 |
import net.sf.basedb.core.ItemNotFoundException; |
2918 |
11 Nov 14 |
nicklas |
20 |
import net.sf.basedb.core.ItemQuery; |
4545 |
28 Jun 17 |
nicklas |
21 |
import net.sf.basedb.core.Job; |
2828 |
16 Oct 14 |
nicklas |
22 |
import net.sf.basedb.core.RawBioAssay; |
6026 |
28 Oct 20 |
nicklas |
23 |
import net.sf.basedb.core.RawDataType; |
2863 |
28 Oct 14 |
nicklas |
24 |
import net.sf.basedb.core.Type; |
2863 |
28 Oct 14 |
nicklas |
25 |
import net.sf.basedb.core.query.Expressions; |
2918 |
11 Nov 14 |
nicklas |
26 |
import net.sf.basedb.core.query.Hql; |
2918 |
11 Nov 14 |
nicklas |
27 |
import net.sf.basedb.core.query.Orders; |
2863 |
28 Oct 14 |
nicklas |
28 |
import net.sf.basedb.core.query.Restrictions; |
2918 |
11 Nov 14 |
nicklas |
29 |
import net.sf.basedb.reggie.Reggie; |
4538 |
22 Jun 17 |
nicklas |
30 |
import net.sf.basedb.util.FileUtil; |
4538 |
22 Jun 17 |
nicklas |
31 |
import net.sf.basedb.util.parser.FlatFileParser; |
4538 |
22 Jun 17 |
nicklas |
32 |
import net.sf.basedb.util.parser.FlatFileParser.LineType; |
4538 |
22 Jun 17 |
nicklas |
33 |
import net.sf.basedb.util.parser.Mapper; |
2828 |
16 Oct 14 |
nicklas |
34 |
|
2828 |
16 Oct 14 |
nicklas |
35 |
/** |
2828 |
16 Oct 14 |
nicklas |
Class for loading information that is related to raw bioassays |
2828 |
16 Oct 14 |
nicklas |
37 |
|
2828 |
16 Oct 14 |
nicklas |
@author nicklas |
2828 |
16 Oct 14 |
nicklas |
@since 2.17 |
2828 |
16 Oct 14 |
nicklas |
40 |
*/ |
2828 |
16 Oct 14 |
nicklas |
41 |
public class Rawbioassay |
2828 |
16 Oct 14 |
nicklas |
42 |
extends ReggieItem<RawBioAssay> |
2828 |
16 Oct 14 |
nicklas |
43 |
{ |
2828 |
16 Oct 14 |
nicklas |
44 |
|
2877 |
30 Oct 14 |
nicklas |
45 |
|
2828 |
16 Oct 14 |
nicklas |
46 |
/** |
2877 |
30 Oct 14 |
nicklas |
Value for the {@link Annotationtype#ANALYSIS_RESULT} annotation |
2877 |
30 Oct 14 |
nicklas |
when the feature extraction was successful. |
2877 |
30 Oct 14 |
nicklas |
@since 2.18 |
2877 |
30 Oct 14 |
nicklas |
50 |
*/ |
2877 |
30 Oct 14 |
nicklas |
51 |
public static final String FEATURE_EXTRACTION_SUCCESSFUL = "Successful"; |
2877 |
30 Oct 14 |
nicklas |
52 |
|
2877 |
30 Oct 14 |
nicklas |
53 |
/** |
2877 |
30 Oct 14 |
nicklas |
Value for the {@link Annotationtype#ANALYSIS_RESULT} annotation when |
2877 |
30 Oct 14 |
nicklas |
the feature extraction failed. |
2877 |
30 Oct 14 |
nicklas |
@since 2.18 |
2877 |
30 Oct 14 |
nicklas |
57 |
*/ |
2877 |
30 Oct 14 |
nicklas |
58 |
public static final String FEATURE_EXTRACTION_FAILED = "Failed"; |
2877 |
30 Oct 14 |
nicklas |
59 |
|
2877 |
30 Oct 14 |
nicklas |
60 |
|
2877 |
30 Oct 14 |
nicklas |
61 |
/** |
2828 |
16 Oct 14 |
nicklas |
Get demuxed sequences item when the id is known. |
2828 |
16 Oct 14 |
nicklas |
63 |
*/ |
2828 |
16 Oct 14 |
nicklas |
64 |
public static Rawbioassay getById(DbControl dc, int id) |
2828 |
16 Oct 14 |
nicklas |
65 |
{ |
2828 |
16 Oct 14 |
nicklas |
66 |
return new Rawbioassay(RawBioAssay.getById(dc, id)); |
2828 |
16 Oct 14 |
nicklas |
67 |
} |
2828 |
16 Oct 14 |
nicklas |
68 |
|
4545 |
28 Jun 17 |
nicklas |
69 |
public static Rawbioassay getByJob(DbControl dc, Job job) |
4545 |
28 Jun 17 |
nicklas |
70 |
{ |
4545 |
28 Jun 17 |
nicklas |
71 |
ItemQuery<RawBioAssay> query = RawBioAssay.getQuery(); |
4545 |
28 Jun 17 |
nicklas |
72 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
4545 |
28 Jun 17 |
nicklas |
73 |
query.restrict(Restrictions.eq(Hql.property("job"), Hql.entity(job))); |
4545 |
28 Jun 17 |
nicklas |
74 |
|
4545 |
28 Jun 17 |
nicklas |
75 |
List<RawBioAssay> list = query.list(dc); |
4545 |
28 Jun 17 |
nicklas |
76 |
if (list.size() > 1) |
4545 |
28 Jun 17 |
nicklas |
77 |
{ |
4545 |
28 Jun 17 |
nicklas |
78 |
throw new InvalidDataException( |
4545 |
28 Jun 17 |
nicklas |
79 |
"More than one item with job " + job.getName() + " was found. " + |
4545 |
28 Jun 17 |
nicklas |
80 |
"This wizard can't be used until that is corrected."); |
4545 |
28 Jun 17 |
nicklas |
81 |
} |
4545 |
28 Jun 17 |
nicklas |
82 |
|
4545 |
28 Jun 17 |
nicklas |
83 |
Rawbioassay raw = null; |
4545 |
28 Jun 17 |
nicklas |
84 |
if (list.size() == 1) |
4545 |
28 Jun 17 |
nicklas |
85 |
{ |
4545 |
28 Jun 17 |
nicklas |
86 |
raw = new Rawbioassay(list.get(0)); |
4545 |
28 Jun 17 |
nicklas |
87 |
} |
4545 |
28 Jun 17 |
nicklas |
88 |
return raw; |
4545 |
28 Jun 17 |
nicklas |
89 |
} |
4545 |
28 Jun 17 |
nicklas |
90 |
|
2918 |
11 Nov 14 |
nicklas |
91 |
/** |
3782 |
11 Mar 16 |
nicklas |
@since 4.3 |
3782 |
11 Mar 16 |
nicklas |
93 |
*/ |
3782 |
11 Mar 16 |
nicklas |
94 |
public static Rawbioassay get(RawBioAssay raw) |
3782 |
11 Mar 16 |
nicklas |
95 |
{ |
3782 |
11 Mar 16 |
nicklas |
96 |
return new Rawbioassay(raw); |
3782 |
11 Mar 16 |
nicklas |
97 |
} |
3782 |
11 Mar 16 |
nicklas |
98 |
|
3782 |
11 Mar 16 |
nicklas |
99 |
/** |
2918 |
11 Nov 14 |
nicklas |
Find all raw bioassay items by case name. This method will check raw bioassays with |
2918 |
11 Nov 14 |
nicklas |
a name matching the case name (eg. xxx.r.m.c.lib.g.k.a.t). |
2918 |
11 Nov 14 |
nicklas |
@since 2.18 |
2918 |
11 Nov 14 |
nicklas |
103 |
*/ |
2918 |
11 Nov 14 |
nicklas |
104 |
public static List<Rawbioassay> findByCaseName(DbControl dc, String name) |
2918 |
11 Nov 14 |
nicklas |
105 |
{ |
2918 |
11 Nov 14 |
nicklas |
// Get rid of suffixes in the name (eg. 'C' which is used for pre-neoadjuvant forms) |
2918 |
11 Nov 14 |
nicklas |
107 |
if (name.length() > 7) name = name.substring(0, 7); |
2918 |
11 Nov 14 |
nicklas |
108 |
|
2918 |
11 Nov 14 |
nicklas |
// Look for a library with the given name |
2918 |
11 Nov 14 |
nicklas |
110 |
ItemQuery<RawBioAssay> query = RawBioAssay.getQuery(); |
2918 |
11 Nov 14 |
nicklas |
111 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
2918 |
11 Nov 14 |
nicklas |
112 |
query.restrict(Restrictions.like(Hql.property("name"), Expressions.parameter("name", name+".%", Type.STRING))); |
2918 |
11 Nov 14 |
nicklas |
113 |
query.order(Orders.asc(Hql.property("name"))); |
2918 |
11 Nov 14 |
nicklas |
114 |
|
2918 |
11 Nov 14 |
nicklas |
115 |
List<RawBioAssay> tmp = query.list(dc); |
2918 |
11 Nov 14 |
nicklas |
116 |
return toList(tmp); |
2918 |
11 Nov 14 |
nicklas |
117 |
} |
2918 |
11 Nov 14 |
nicklas |
118 |
|
2918 |
11 Nov 14 |
nicklas |
119 |
|
2828 |
16 Oct 14 |
nicklas |
120 |
public static List<Rawbioassay> toList(Collection<RawBioAssay> bioassays) |
2828 |
16 Oct 14 |
nicklas |
121 |
{ |
2828 |
16 Oct 14 |
nicklas |
122 |
List<Rawbioassay> lib = new ArrayList<Rawbioassay>(bioassays.size()); |
2828 |
16 Oct 14 |
nicklas |
123 |
for (RawBioAssay raw : bioassays) |
2828 |
16 Oct 14 |
nicklas |
124 |
{ |
2828 |
16 Oct 14 |
nicklas |
125 |
lib.add(new Rawbioassay(raw)); |
2828 |
16 Oct 14 |
nicklas |
126 |
} |
2828 |
16 Oct 14 |
nicklas |
127 |
return lib; |
2828 |
16 Oct 14 |
nicklas |
128 |
} |
2828 |
16 Oct 14 |
nicklas |
129 |
|
2828 |
16 Oct 14 |
nicklas |
130 |
|
2828 |
16 Oct 14 |
nicklas |
131 |
private Rawbioassay(RawBioAssay bioAssay) |
2828 |
16 Oct 14 |
nicklas |
132 |
{ |
2828 |
16 Oct 14 |
nicklas |
133 |
super(bioAssay); |
2828 |
16 Oct 14 |
nicklas |
134 |
|
2828 |
16 Oct 14 |
nicklas |
135 |
} |
2828 |
16 Oct 14 |
nicklas |
136 |
|
2828 |
16 Oct 14 |
nicklas |
137 |
/** |
2828 |
16 Oct 14 |
nicklas |
Get the raw bioassay that represents the raw data in BASE. |
2828 |
16 Oct 14 |
nicklas |
139 |
*/ |
2828 |
16 Oct 14 |
nicklas |
140 |
public RawBioAssay getRawBioAssay() |
2828 |
16 Oct 14 |
nicklas |
141 |
{ |
2828 |
16 Oct 14 |
nicklas |
142 |
return getItem(); |
2828 |
16 Oct 14 |
nicklas |
143 |
} |
2828 |
16 Oct 14 |
nicklas |
144 |
|
2828 |
16 Oct 14 |
nicklas |
145 |
public Library getLibrary(DbControl dc) |
2828 |
16 Oct 14 |
nicklas |
146 |
{ |
2828 |
16 Oct 14 |
nicklas |
147 |
return Library.getById(dc, getItem().getParentExtract().getId()); |
2828 |
16 Oct 14 |
nicklas |
148 |
} |
2828 |
16 Oct 14 |
nicklas |
149 |
|
2828 |
16 Oct 14 |
nicklas |
150 |
public AlignedSequences getAlignedSequences(DbControl dc) |
2828 |
16 Oct 14 |
nicklas |
151 |
{ |
2828 |
16 Oct 14 |
nicklas |
152 |
return AlignedSequences.getById(dc, getItem().getParentBioAssay().getId()); |
2828 |
16 Oct 14 |
nicklas |
153 |
} |
2828 |
16 Oct 14 |
nicklas |
154 |
|
2828 |
16 Oct 14 |
nicklas |
155 |
|
2828 |
16 Oct 14 |
nicklas |
156 |
@Override |
2828 |
16 Oct 14 |
nicklas |
157 |
protected void initJSON(JSONObject json) |
2828 |
16 Oct 14 |
nicklas |
158 |
{ |
2828 |
16 Oct 14 |
nicklas |
159 |
super.initJSON(json); |
6116 |
05 Feb 21 |
nicklas |
160 |
RawBioAssay rba = getRawBioAssay(); |
6116 |
05 Feb 21 |
nicklas |
161 |
json.put("rawDataType", rba.getRawDataType().getId()); |
2828 |
16 Oct 14 |
nicklas |
162 |
} |
2828 |
16 Oct 14 |
nicklas |
163 |
|
2863 |
28 Oct 14 |
nicklas |
164 |
/** |
3531 |
05 Oct 15 |
nicklas |
Get the file of the given type. |
3531 |
05 Oct 15 |
nicklas |
@since 3.7 |
3531 |
05 Oct 15 |
nicklas |
167 |
*/ |
3531 |
05 Oct 15 |
nicklas |
168 |
public File getFile(DbControl dc, Datafiletype fileType) |
3531 |
05 Oct 15 |
nicklas |
169 |
{ |
3531 |
05 Oct 15 |
nicklas |
170 |
RawBioAssay item = getItem(); |
3531 |
05 Oct 15 |
nicklas |
171 |
File f = null; |
3531 |
05 Oct 15 |
nicklas |
172 |
if (item.hasFileSet()) |
3531 |
05 Oct 15 |
nicklas |
173 |
{ |
3531 |
05 Oct 15 |
nicklas |
174 |
FileSetMember member = item.getFileSet().getMember(fileType.load(dc)); |
3531 |
05 Oct 15 |
nicklas |
175 |
if (member != null) f = member.getFile(); |
3531 |
05 Oct 15 |
nicklas |
176 |
} |
3531 |
05 Oct 15 |
nicklas |
177 |
return f; |
3531 |
05 Oct 15 |
nicklas |
178 |
} |
3531 |
05 Oct 15 |
nicklas |
179 |
|
3531 |
05 Oct 15 |
nicklas |
180 |
/** |
2863 |
28 Oct 14 |
nicklas |
Calculate sum of fpkm values for the given genes. |
4538 |
22 Jun 17 |
nicklas |
If data exists in the database that data is used, |
4538 |
22 Jun 17 |
nicklas |
otherwise data from the cufflinks file is used. |
4538 |
22 Jun 17 |
nicklas |
184 |
|
4665 |
31 Jan 18 |
nicklas |
NOTE! Currently only implemented for Cufflinks data. |
4665 |
31 Jan 18 |
nicklas |
186 |
|
2863 |
28 Oct 14 |
nicklas |
@return A map with key=gene and value=sum of fpkm |
2863 |
28 Oct 14 |
nicklas |
@since 2.18 |
2863 |
28 Oct 14 |
nicklas |
189 |
*/ |
2863 |
28 Oct 14 |
nicklas |
190 |
public Map<String, Float> getFpkmSum(DbControl dc, Collection<String> genes) |
2863 |
28 Oct 14 |
nicklas |
191 |
{ |
6026 |
28 Oct 20 |
nicklas |
192 |
Map<String, Float> sums = getFpkmSumFromFile(dc, genes); |
4538 |
22 Jun 17 |
nicklas |
193 |
return sums; |
4538 |
22 Jun 17 |
nicklas |
194 |
} |
4538 |
22 Jun 17 |
nicklas |
195 |
|
4538 |
22 Jun 17 |
nicklas |
196 |
/** |
4538 |
22 Jun 17 |
nicklas |
Calculate sum of fpkm values for the given genes. |
4665 |
31 Jan 18 |
nicklas |
198 |
|
6026 |
28 Oct 20 |
nicklas |
NOTE! Currently implemented for Cufflinks and StringTie data. |
6026 |
28 Oct 20 |
nicklas |
200 |
|
4538 |
22 Jun 17 |
nicklas |
@return A map with key=gene and value=sum of fpkm |
4538 |
22 Jun 17 |
nicklas |
@since 4.11 |
4538 |
22 Jun 17 |
nicklas |
203 |
*/ |
6026 |
28 Oct 20 |
nicklas |
204 |
public Map<String, Float> getFpkmSumFromFile(DbControl dc, Collection<String> genes) |
4538 |
22 Jun 17 |
nicklas |
205 |
{ |
6026 |
28 Oct 20 |
nicklas |
206 |
File dataFile = null; |
6026 |
28 Oct 20 |
nicklas |
207 |
RawDataType type = getItem().getRawDataType(); |
6026 |
28 Oct 20 |
nicklas |
208 |
FlatFileParser ffp = new FlatFileParser(); |
4665 |
31 Jan 18 |
nicklas |
209 |
|
6026 |
28 Oct 20 |
nicklas |
210 |
String geneCol = null; |
6026 |
28 Oct 20 |
nicklas |
211 |
String fpkmCol = "FPKM"; |
6026 |
28 Oct 20 |
nicklas |
212 |
if (Rawdatatype.CUFFLINKS.getRawDataType().equals(type)) |
2863 |
28 Oct 14 |
nicklas |
213 |
{ |
6026 |
28 Oct 20 |
nicklas |
214 |
dataFile = getFile(dc, Datafiletype.FPKM); |
6026 |
28 Oct 20 |
nicklas |
215 |
if (dataFile == null) |
2863 |
28 Oct 14 |
nicklas |
216 |
{ |
6026 |
28 Oct 20 |
nicklas |
217 |
throw new ItemNotFoundException("Can't find " + Datafiletype.FPKM.getName() + " for raw bioassay " + getName()); |
2863 |
28 Oct 14 |
nicklas |
218 |
} |
6026 |
28 Oct 20 |
nicklas |
219 |
ffp.setDataHeaderRegexp(Pattern.compile(".*gene_short_name\\t.*FPKM.*")); |
6059 |
17 Nov 20 |
nicklas |
220 |
geneCol = "gene_short_name"; |
2863 |
28 Oct 14 |
nicklas |
221 |
} |
6026 |
28 Oct 20 |
nicklas |
222 |
else if (Rawdatatype.STRINGTIE.getRawDataType().equals(type)) |
2863 |
28 Oct 14 |
nicklas |
223 |
{ |
6026 |
28 Oct 20 |
nicklas |
224 |
dataFile = getFile(dc, Datafiletype.GENERIC_RAWDATA); |
6026 |
28 Oct 20 |
nicklas |
225 |
if (dataFile == null) |
6026 |
28 Oct 20 |
nicklas |
226 |
{ |
6026 |
28 Oct 20 |
nicklas |
227 |
throw new ItemNotFoundException("Can't find gene.tsv for raw bioassay " + getName()); |
6026 |
28 Oct 20 |
nicklas |
228 |
} |
6026 |
28 Oct 20 |
nicklas |
229 |
ffp.setDataHeaderRegexp(Pattern.compile(".*Gene Name\\t.*FPKM.*")); |
6026 |
28 Oct 20 |
nicklas |
230 |
geneCol = "Gene Name"; |
2863 |
28 Oct 14 |
nicklas |
231 |
} |
6026 |
28 Oct 20 |
nicklas |
232 |
else |
2863 |
28 Oct 14 |
nicklas |
233 |
{ |
6026 |
28 Oct 20 |
nicklas |
234 |
throw new InvalidDataException(type.getName() + " is not supported: " + getName()); |
2863 |
28 Oct 14 |
nicklas |
235 |
} |
4665 |
31 Jan 18 |
nicklas |
236 |
|
4538 |
22 Jun 17 |
nicklas |
237 |
Map<String, Float> sums = new HashMap<String, Float>(genes.size()); |
2828 |
16 Oct 14 |
nicklas |
238 |
|
4538 |
22 Jun 17 |
nicklas |
239 |
InputStream fpkmIn = null; |
4538 |
22 Jun 17 |
nicklas |
240 |
try |
4538 |
22 Jun 17 |
nicklas |
241 |
{ |
6026 |
28 Oct 20 |
nicklas |
242 |
fpkmIn = dataFile.getDownloadStream(0); |
4538 |
22 Jun 17 |
nicklas |
243 |
|
4538 |
22 Jun 17 |
nicklas |
244 |
ffp.setDataSplitterRegexp(Pattern.compile("\\t")); |
4538 |
22 Jun 17 |
nicklas |
245 |
ffp.setInputStream(fpkmIn, "UTF-8"); |
4538 |
22 Jun 17 |
nicklas |
246 |
ffp.setIgnoreNonExistingColumns(false); |
4538 |
22 Jun 17 |
nicklas |
247 |
|
4538 |
22 Jun 17 |
nicklas |
248 |
LineType line = ffp.parseHeaders(); |
4538 |
22 Jun 17 |
nicklas |
249 |
if (line != LineType.DATA_HEADER) |
4538 |
22 Jun 17 |
nicklas |
250 |
{ |
6026 |
28 Oct 20 |
nicklas |
251 |
throw new IOException("Could not find FPKM data in file: " + dataFile.getName()); |
4538 |
22 Jun 17 |
nicklas |
252 |
} |
4538 |
22 Jun 17 |
nicklas |
253 |
|
6026 |
28 Oct 20 |
nicklas |
254 |
Mapper geneMapper = ffp.getMapper("\\" + geneCol + "\\"); |
6026 |
28 Oct 20 |
nicklas |
255 |
Mapper fpkmMapper = ffp.getMapper("\\" + fpkmCol + "\\"); |
4538 |
22 Jun 17 |
nicklas |
256 |
|
4538 |
22 Jun 17 |
nicklas |
257 |
while (ffp.hasMoreData()) |
4538 |
22 Jun 17 |
nicklas |
258 |
{ |
4538 |
22 Jun 17 |
nicklas |
259 |
FlatFileParser.Data data = ffp.nextData(); |
5364 |
16 Apr 19 |
nicklas |
260 |
String gene = geneMapper.getString(data); |
4538 |
22 Jun 17 |
nicklas |
261 |
|
4538 |
22 Jun 17 |
nicklas |
262 |
if (genes.contains(gene)) |
4538 |
22 Jun 17 |
nicklas |
263 |
{ |
4538 |
22 Jun 17 |
nicklas |
264 |
Float fpkm = fpkmMapper.getFloat(data); |
4538 |
22 Jun 17 |
nicklas |
265 |
Float s = sums.get(gene); |
4538 |
22 Jun 17 |
nicklas |
266 |
sums.put(gene, add(s, fpkm)); |
4538 |
22 Jun 17 |
nicklas |
267 |
} |
4538 |
22 Jun 17 |
nicklas |
268 |
} |
4538 |
22 Jun 17 |
nicklas |
269 |
} |
4538 |
22 Jun 17 |
nicklas |
270 |
catch (IOException ex) |
4538 |
22 Jun 17 |
nicklas |
271 |
{ |
4538 |
22 Jun 17 |
nicklas |
272 |
throw new BaseException(ex); |
4538 |
22 Jun 17 |
nicklas |
273 |
} |
4538 |
22 Jun 17 |
nicklas |
274 |
finally |
4538 |
22 Jun 17 |
nicklas |
275 |
{ |
4538 |
22 Jun 17 |
nicklas |
276 |
FileUtil.close(fpkmIn); |
4538 |
22 Jun 17 |
nicklas |
277 |
} |
4538 |
22 Jun 17 |
nicklas |
278 |
return sums; |
4538 |
22 Jun 17 |
nicklas |
279 |
} |
4538 |
22 Jun 17 |
nicklas |
280 |
|
4667 |
01 Feb 18 |
nicklas |
281 |
private void checkRawDataType(Rawdatatype rawDataType) |
4665 |
31 Jan 18 |
nicklas |
282 |
{ |
4665 |
31 Jan 18 |
nicklas |
283 |
RawBioAssay raw = getItem(); |
4667 |
01 Feb 18 |
nicklas |
284 |
if (!raw.getRawDataType().equals(rawDataType.getRawDataType())) |
4665 |
31 Jan 18 |
nicklas |
285 |
{ |
4667 |
01 Feb 18 |
nicklas |
286 |
throw new InvalidDataException("" + raw.getName() + " is not a '" + rawDataType.getId() + "' raw bioassay."); |
4665 |
31 Jan 18 |
nicklas |
287 |
} |
4665 |
31 Jan 18 |
nicklas |
288 |
} |
4665 |
31 Jan 18 |
nicklas |
289 |
|
4538 |
22 Jun 17 |
nicklas |
290 |
private Float add(Float f1, Float f2) |
4538 |
22 Jun 17 |
nicklas |
291 |
{ |
4538 |
22 Jun 17 |
nicklas |
292 |
if (f1 == null) return f2; |
4538 |
22 Jun 17 |
nicklas |
293 |
if (f2 == null) return f1; |
4538 |
22 Jun 17 |
nicklas |
294 |
return f1+f2; |
4538 |
22 Jun 17 |
nicklas |
295 |
} |
2828 |
16 Oct 14 |
nicklas |
296 |
} |