3936 |
16 May 16 |
nicklas |
1 |
package net.sf.basedb.reggie.plugins.release; |
3936 |
16 May 16 |
nicklas |
2 |
|
5104 |
16 Nov 18 |
nicklas |
3 |
import java.util.HashSet; |
4469 |
26 Apr 17 |
nicklas |
4 |
import java.util.List; |
5104 |
16 Nov 18 |
nicklas |
5 |
import java.util.Set; |
5104 |
16 Nov 18 |
nicklas |
6 |
import java.util.TreeSet; |
4469 |
26 Apr 17 |
nicklas |
7 |
|
4385 |
08 Mar 17 |
nicklas |
8 |
import org.json.simple.JSONArray; |
4371 |
02 Mar 17 |
nicklas |
9 |
import org.json.simple.JSONObject; |
4371 |
02 Mar 17 |
nicklas |
10 |
|
3936 |
16 May 16 |
nicklas |
11 |
import net.sf.basedb.core.DbControl; |
3936 |
16 May 16 |
nicklas |
12 |
import net.sf.basedb.core.DerivedBioAssay; |
4402 |
17 Mar 17 |
nicklas |
13 |
import net.sf.basedb.core.Item; |
4472 |
27 Apr 17 |
nicklas |
14 |
import net.sf.basedb.core.Type; |
3936 |
16 May 16 |
nicklas |
15 |
import net.sf.basedb.reggie.dao.Annotationtype; |
4385 |
08 Mar 17 |
nicklas |
16 |
import net.sf.basedb.reggie.dao.Datafiletype; |
5104 |
16 Nov 18 |
nicklas |
17 |
import net.sf.basedb.reggie.dao.DemuxedSequences; |
5104 |
16 Nov 18 |
nicklas |
18 |
import net.sf.basedb.reggie.dao.Library; |
5102 |
16 Nov 18 |
nicklas |
19 |
import net.sf.basedb.reggie.dao.MergedSequences; |
5550 |
09 Aug 19 |
nicklas |
20 |
import net.sf.basedb.reggie.dao.Pipeline; |
5104 |
16 Nov 18 |
nicklas |
21 |
import net.sf.basedb.reggie.dao.PooledLibrary; |
5104 |
16 Nov 18 |
nicklas |
22 |
import net.sf.basedb.reggie.dao.SequencingRun; |
4385 |
08 Mar 17 |
nicklas |
23 |
import net.sf.basedb.reggie.json.FilteredJSONArray; |
5104 |
16 Nov 18 |
nicklas |
24 |
import net.sf.basedb.util.Values; |
4385 |
08 Mar 17 |
nicklas |
25 |
import net.sf.basedb.util.filter.NotNullFilter; |
3936 |
16 May 16 |
nicklas |
26 |
|
3936 |
16 May 16 |
nicklas |
27 |
/** |
3936 |
16 May 16 |
nicklas |
Cohort writer implementation for the merged sequences data table. |
3936 |
16 May 16 |
nicklas |
@since 4.5 |
3936 |
16 May 16 |
nicklas |
30 |
*/ |
3936 |
16 May 16 |
nicklas |
31 |
public class MergedWriter |
3936 |
16 May 16 |
nicklas |
32 |
extends CohortWriter |
3936 |
16 May 16 |
nicklas |
33 |
{ |
3936 |
16 May 16 |
nicklas |
34 |
|
4422 |
24 Mar 17 |
nicklas |
35 |
private final ScriptWriter scriptWriter; |
3936 |
16 May 16 |
nicklas |
36 |
|
5090 |
14 Nov 18 |
nicklas |
37 |
public MergedWriter(DbControl dc, ReleaseWriterOptions options, ScriptWriter scriptWriter) |
3936 |
16 May 16 |
nicklas |
38 |
{ |
5090 |
14 Nov 18 |
nicklas |
39 |
super(dc, options); |
4422 |
24 Mar 17 |
nicklas |
40 |
this.scriptWriter = scriptWriter; |
3936 |
16 May 16 |
nicklas |
41 |
} |
3936 |
16 May 16 |
nicklas |
42 |
|
4371 |
02 Mar 17 |
nicklas |
43 |
@Override |
5091 |
14 Nov 18 |
nicklas |
44 |
public JSONArray toJSONObjects(CohortItem item) |
4371 |
02 Mar 17 |
nicklas |
45 |
{ |
5550 |
09 Aug 19 |
nicklas |
46 |
JSONArray json = new JSONArray(); |
5550 |
09 Aug 19 |
nicklas |
47 |
|
5550 |
09 Aug 19 |
nicklas |
48 |
addRnaSeqItems(json, item); |
5550 |
09 Aug 19 |
nicklas |
49 |
addMipsItems(json, item); |
5550 |
09 Aug 19 |
nicklas |
50 |
|
5550 |
09 Aug 19 |
nicklas |
51 |
return json.size() == 0 ? null : json; |
5550 |
09 Aug 19 |
nicklas |
52 |
} |
5550 |
09 Aug 19 |
nicklas |
53 |
|
5550 |
09 Aug 19 |
nicklas |
54 |
private void addRnaSeqItems(JSONArray json, CohortItem item) |
5550 |
09 Aug 19 |
nicklas |
55 |
{ |
5550 |
09 Aug 19 |
nicklas |
56 |
List<MergedSequences> mergedSequences = item.getMergedSequences(Pipeline.RNA_SEQ); |
5550 |
09 Aug 19 |
nicklas |
57 |
if (mergedSequences.size() == 0) return; |
5104 |
16 Nov 18 |
nicklas |
58 |
DbControl dc = item.getDbControl(); |
4371 |
02 Mar 17 |
nicklas |
59 |
|
5102 |
16 Nov 18 |
nicklas |
60 |
for (MergedSequences ms : mergedSequences) |
4472 |
27 Apr 17 |
nicklas |
61 |
{ |
5102 |
16 Nov 18 |
nicklas |
62 |
DerivedBioAssay merged = ms.getDerivedBioAssay(); |
5550 |
09 Aug 19 |
nicklas |
63 |
Library lib = ms.getLibrary(dc); |
5102 |
16 Nov 18 |
nicklas |
64 |
|
5102 |
16 Nov 18 |
nicklas |
65 |
JSONObject jsonMerged = new JSONObject(); |
5102 |
16 Nov 18 |
nicklas |
66 |
jsonMerged.put("name", item.toReleaseId(merged.getName())); |
5102 |
16 Nov 18 |
nicklas |
67 |
jsonMerged.put("type", merged.getType().name()); |
5102 |
16 Nov 18 |
nicklas |
68 |
jsonMerged.put("subtype", getName(merged.getItemSubtype())); |
5102 |
16 Nov 18 |
nicklas |
69 |
jsonMerged.put("extract", item.toReleaseId(lib.getName())); |
5102 |
16 Nov 18 |
nicklas |
70 |
|
5102 |
16 Nov 18 |
nicklas |
71 |
JSONArray jsonAnnotations = new FilteredJSONArray(new NotNullFilter<>(false)); |
5102 |
16 Nov 18 |
nicklas |
72 |
jsonMerged.put("annotations", jsonAnnotations); |
5550 |
09 Aug 19 |
nicklas |
73 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.PIPELINE, merged, null)); |
5102 |
16 Nov 18 |
nicklas |
74 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.PF_READS, merged, null)); |
5102 |
16 Nov 18 |
nicklas |
75 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.PT_READS, merged, null)); |
5102 |
16 Nov 18 |
nicklas |
76 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.ADAPTER_READS, merged, null)); |
5102 |
16 Nov 18 |
nicklas |
77 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.FRAGMENT_SIZE_AVG, merged, null)); |
5102 |
16 Nov 18 |
nicklas |
78 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.FRAGMENT_SIZE_STDEV, merged, null)); |
6424 |
28 Sep 21 |
nicklas |
79 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.READLENGTH_AVG_R1, merged, null)); |
6424 |
28 Sep 21 |
nicklas |
80 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.READLENGTH_AVG_R2, merged, null)); |
5102 |
16 Nov 18 |
nicklas |
81 |
|
5550 |
09 Aug 19 |
nicklas |
// Load information from parent items: DemuxedSequence, SequencingRun and PooledLibrary |
5550 |
09 Aug 19 |
nicklas |
83 |
List<DemuxedSequences> demuxedSequences = item.getDemuxedSequences(ms); |
5550 |
09 Aug 19 |
nicklas |
84 |
List<SequencingRun> sequencingRuns = item.getSequencingRuns(ms); |
5550 |
09 Aug 19 |
nicklas |
85 |
List<PooledLibrary> poolsWithLib = item.getPools(lib); |
5550 |
09 Aug 19 |
nicklas |
86 |
|
6010 |
18 Sep 20 |
nicklas |
87 |
Set<String> demuxSoftware = getDemuxSoftwareNames(item, demuxedSequences); |
5550 |
09 Aug 19 |
nicklas |
88 |
Set<String> readStrings = getReadStrings(item, demuxedSequences); |
5550 |
09 Aug 19 |
nicklas |
89 |
Set<String> poolNames = getSequencedPoolNames(item, demuxedSequences, poolsWithLib); |
6010 |
18 Sep 20 |
nicklas |
90 |
Set<String> sequencerSerials = getSequencerSerials(item, sequencingRuns); |
6010 |
18 Sep 20 |
nicklas |
91 |
Set<String> sequencerModels = getSequencerModels(item, sequencingRuns); |
5550 |
09 Aug 19 |
nicklas |
92 |
|
6010 |
18 Sep 20 |
nicklas |
93 |
jsonAnnotations.add(item.createAnnotationJSON("DemuxSoftware", Values.getString(demuxSoftware, ";", true))); |
5102 |
16 Nov 18 |
nicklas |
94 |
jsonAnnotations.add(item.createAnnotationJSON("ReadString", Values.getString(readStrings, ";", true))); |
6010 |
18 Sep 20 |
nicklas |
95 |
jsonAnnotations.add(item.createAnnotationJSON("SequencerSerial", Values.getString(sequencerSerials, ";", true))); |
6010 |
18 Sep 20 |
nicklas |
96 |
jsonAnnotations.add(item.createAnnotationJSON("SequencerModel", Values.getString(sequencerModels, ";", true))); |
5550 |
09 Aug 19 |
nicklas |
97 |
jsonAnnotations.add(item.createAnnotationJSON("PoolName", Values.getString(poolNames, ";", true))); |
5550 |
09 Aug 19 |
nicklas |
98 |
|
5550 |
09 Aug 19 |
nicklas |
// Folders and files |
5550 |
09 Aug 19 |
nicklas |
100 |
String dataFilesFolder = (String)item.getAnnotationValue(Annotationtype.DATA_FILES_FOLDER, merged); |
5550 |
09 Aug 19 |
nicklas |
101 |
String releaseDataFilesFolder = item.toReleaseFolder(dataFilesFolder); |
5550 |
09 Aug 19 |
nicklas |
102 |
JSONObject jsonDataFilesFolder = item.createAnnotationJSON(Annotationtype.DATA_FILES_FOLDER.getName(), releaseDataFilesFolder); |
5550 |
09 Aug 19 |
nicklas |
103 |
jsonAnnotations.add(jsonDataFilesFolder); |
5102 |
16 Nov 18 |
nicklas |
104 |
|
5550 |
09 Aug 19 |
nicklas |
105 |
JSONArray jsonFiles = new FilteredJSONArray(new NotNullFilter<>(false)); |
5550 |
09 Aug 19 |
nicklas |
106 |
jsonMerged.put("files", jsonFiles); |
5550 |
09 Aug 19 |
nicklas |
107 |
jsonFiles.addAll(item.getDataFilesJSON(Datafiletype.FASTQ, merged, null, true)); |
5550 |
09 Aug 19 |
nicklas |
108 |
|
5550 |
09 Aug 19 |
nicklas |
109 |
if (scriptWriter != null) |
5102 |
16 Nov 18 |
nicklas |
110 |
{ |
5550 |
09 Aug 19 |
nicklas |
111 |
scriptWriter.addFiles(releaseDataFilesFolder, dataFilesFolder, null, jsonFiles); |
5102 |
16 Nov 18 |
nicklas |
112 |
} |
5550 |
09 Aug 19 |
nicklas |
113 |
|
5550 |
09 Aug 19 |
nicklas |
114 |
json.add(jsonMerged); |
5550 |
09 Aug 19 |
nicklas |
115 |
} |
5550 |
09 Aug 19 |
nicklas |
116 |
} |
5550 |
09 Aug 19 |
nicklas |
117 |
|
5550 |
09 Aug 19 |
nicklas |
118 |
private void addMipsItems(JSONArray json, CohortItem item) |
5550 |
09 Aug 19 |
nicklas |
119 |
{ |
5550 |
09 Aug 19 |
nicklas |
120 |
|
5550 |
09 Aug 19 |
nicklas |
121 |
List<MergedSequences> mergedSequences = item.getMergedSequences(Pipeline.MIPS); |
5550 |
09 Aug 19 |
nicklas |
122 |
if (mergedSequences.size() == 0) return; |
5550 |
09 Aug 19 |
nicklas |
123 |
DbControl dc = item.getDbControl(); |
5550 |
09 Aug 19 |
nicklas |
124 |
|
5550 |
09 Aug 19 |
nicklas |
125 |
for (MergedSequences ms : mergedSequences) |
5550 |
09 Aug 19 |
nicklas |
126 |
{ |
5550 |
09 Aug 19 |
nicklas |
127 |
DerivedBioAssay merged = ms.getDerivedBioAssay(); |
5550 |
09 Aug 19 |
nicklas |
128 |
Library lib = ms.getLibrary(dc); |
5550 |
09 Aug 19 |
nicklas |
129 |
|
5550 |
09 Aug 19 |
nicklas |
130 |
JSONObject jsonMerged = new JSONObject(); |
5550 |
09 Aug 19 |
nicklas |
131 |
jsonMerged.put("name", item.toReleaseId(merged.getName())); |
5550 |
09 Aug 19 |
nicklas |
132 |
jsonMerged.put("type", merged.getType().name()); |
5550 |
09 Aug 19 |
nicklas |
133 |
jsonMerged.put("subtype", getName(merged.getItemSubtype())); |
5550 |
09 Aug 19 |
nicklas |
134 |
jsonMerged.put("extract", item.toReleaseId(lib.getName())); |
5550 |
09 Aug 19 |
nicklas |
135 |
|
5550 |
09 Aug 19 |
nicklas |
136 |
JSONArray jsonAnnotations = new FilteredJSONArray(new NotNullFilter<>(false)); |
5550 |
09 Aug 19 |
nicklas |
137 |
jsonMerged.put("annotations", jsonAnnotations); |
5550 |
09 Aug 19 |
nicklas |
138 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.PIPELINE, merged, null)); |
5550 |
09 Aug 19 |
nicklas |
139 |
jsonAnnotations.add(item.getAnnotationJSON(Annotationtype.PF_READS, merged, null)); |
5550 |
09 Aug 19 |
nicklas |
140 |
|
5550 |
09 Aug 19 |
nicklas |
// Load information from parent items: DemuxedSequence, SequencingRun and PooledLibrary |
5550 |
09 Aug 19 |
nicklas |
142 |
List<DemuxedSequences> demuxedSequences = item.getDemuxedSequences(ms); |
5550 |
09 Aug 19 |
nicklas |
143 |
List<SequencingRun> sequencingRuns = item.getSequencingRuns(ms); |
5550 |
09 Aug 19 |
nicklas |
144 |
List<PooledLibrary> poolsWithLib = item.getPools(lib); |
5550 |
09 Aug 19 |
nicklas |
145 |
|
5550 |
09 Aug 19 |
nicklas |
146 |
Set<String> readStrings = getReadStrings(item, demuxedSequences); |
6010 |
18 Sep 20 |
nicklas |
147 |
Set<String> demuxSoftware = getDemuxSoftwareNames(item, demuxedSequences); |
5550 |
09 Aug 19 |
nicklas |
148 |
Set<String> poolNames = getSequencedPoolNames(item, demuxedSequences, poolsWithLib); |
6010 |
18 Sep 20 |
nicklas |
149 |
Set<String> sequencerSerials = getSequencerSerials(item, sequencingRuns); |
6010 |
18 Sep 20 |
nicklas |
150 |
Set<String> sequencerModels = getSequencerModels(item, sequencingRuns); |
5550 |
09 Aug 19 |
nicklas |
151 |
|
6010 |
18 Sep 20 |
nicklas |
152 |
jsonAnnotations.add(item.createAnnotationJSON("DemuxSoftware", Values.getString(demuxSoftware, ";", true))); |
5550 |
09 Aug 19 |
nicklas |
153 |
jsonAnnotations.add(item.createAnnotationJSON("ReadString", Values.getString(readStrings, ";", true))); |
6010 |
18 Sep 20 |
nicklas |
154 |
jsonAnnotations.add(item.createAnnotationJSON("SequencerSerial", Values.getString(sequencerSerials, ";", true))); |
6010 |
18 Sep 20 |
nicklas |
155 |
jsonAnnotations.add(item.createAnnotationJSON("SequencerModel", Values.getString(sequencerModels, ";", true))); |
5102 |
16 Nov 18 |
nicklas |
156 |
jsonAnnotations.add(item.createAnnotationJSON("PoolName", Values.getString(poolNames, ";", true))); |
5106 |
19 Nov 18 |
nicklas |
157 |
|
5102 |
16 Nov 18 |
nicklas |
// Folders and files |
5102 |
16 Nov 18 |
nicklas |
159 |
String dataFilesFolder = (String)item.getAnnotationValue(Annotationtype.DATA_FILES_FOLDER, merged); |
5106 |
19 Nov 18 |
nicklas |
160 |
String releaseDataFilesFolder = item.toReleaseFolder(dataFilesFolder); |
5102 |
16 Nov 18 |
nicklas |
161 |
JSONObject jsonDataFilesFolder = item.createAnnotationJSON(Annotationtype.DATA_FILES_FOLDER.getName(), releaseDataFilesFolder); |
5102 |
16 Nov 18 |
nicklas |
162 |
jsonAnnotations.add(jsonDataFilesFolder); |
5102 |
16 Nov 18 |
nicklas |
163 |
|
5102 |
16 Nov 18 |
nicklas |
164 |
JSONArray jsonFiles = new FilteredJSONArray(new NotNullFilter<>(false)); |
5102 |
16 Nov 18 |
nicklas |
165 |
jsonMerged.put("files", jsonFiles); |
5142 |
22 Nov 18 |
nicklas |
166 |
jsonFiles.addAll(item.getDataFilesJSON(Datafiletype.FASTQ, merged, null, true)); |
5106 |
19 Nov 18 |
nicklas |
167 |
|
5102 |
16 Nov 18 |
nicklas |
168 |
if (scriptWriter != null) |
5102 |
16 Nov 18 |
nicklas |
169 |
{ |
5106 |
19 Nov 18 |
nicklas |
170 |
scriptWriter.addFiles(releaseDataFilesFolder, dataFilesFolder, null, jsonFiles); |
5102 |
16 Nov 18 |
nicklas |
171 |
} |
5102 |
16 Nov 18 |
nicklas |
172 |
|
5102 |
16 Nov 18 |
nicklas |
173 |
json.add(jsonMerged); |
4472 |
27 Apr 17 |
nicklas |
174 |
} |
4371 |
02 Mar 17 |
nicklas |
175 |
} |
4371 |
02 Mar 17 |
nicklas |
176 |
|
5550 |
09 Aug 19 |
nicklas |
177 |
/** |
5550 |
09 Aug 19 |
nicklas |
Get the serial number of the sequencers that have been involved in |
5550 |
09 Aug 19 |
nicklas |
creating the merged sequences. Typically it is a single sequencer, but |
5550 |
09 Aug 19 |
nicklas |
there are cases where data comes from multiple sequencing runs on different |
5550 |
09 Aug 19 |
nicklas |
sequencers. |
5550 |
09 Aug 19 |
nicklas |
182 |
*/ |
5550 |
09 Aug 19 |
nicklas |
183 |
private Set<String> getSequencerSerials(CohortItem item, List<SequencingRun> sequencingRuns) |
5550 |
09 Aug 19 |
nicklas |
184 |
{ |
5550 |
09 Aug 19 |
nicklas |
185 |
Set<String> sequencers = new TreeSet<>(); |
5550 |
09 Aug 19 |
nicklas |
186 |
for (SequencingRun sr : sequencingRuns) |
5550 |
09 Aug 19 |
nicklas |
187 |
{ |
5861 |
11 Mar 20 |
nicklas |
188 |
String sn = (String)item.getAnnotationValue(Annotationtype.SERIAL_NUMBER, sr.getItem().getHardware()); |
5861 |
11 Mar 20 |
nicklas |
189 |
if (sn != null) sequencers.add(sn); |
5550 |
09 Aug 19 |
nicklas |
190 |
} |
5550 |
09 Aug 19 |
nicklas |
191 |
return sequencers; |
5550 |
09 Aug 19 |
nicklas |
192 |
} |
4402 |
17 Mar 17 |
nicklas |
193 |
|
5550 |
09 Aug 19 |
nicklas |
194 |
/** |
6010 |
18 Sep 20 |
nicklas |
Get the model of the sequencers that have been involved in |
6010 |
18 Sep 20 |
nicklas |
creating the merged sequences. Typically it is a single sequencer, |
6010 |
18 Sep 20 |
nicklas |
but there are cases where data comes from multiple sequencing |
6010 |
18 Sep 20 |
nicklas |
runs on different sequencers. |
6010 |
18 Sep 20 |
nicklas |
@since 4.27.4 |
6010 |
18 Sep 20 |
nicklas |
200 |
*/ |
6010 |
18 Sep 20 |
nicklas |
201 |
private Set<String> getSequencerModels(CohortItem item, List<SequencingRun> sequencingRuns) |
6010 |
18 Sep 20 |
nicklas |
202 |
{ |
6010 |
18 Sep 20 |
nicklas |
203 |
Set<String> models = new TreeSet<>(); |
6010 |
18 Sep 20 |
nicklas |
204 |
for (SequencingRun sr : sequencingRuns) |
6010 |
18 Sep 20 |
nicklas |
205 |
{ |
6010 |
18 Sep 20 |
nicklas |
206 |
String m = (String)item.getAnnotationValue(Annotationtype.HARDWARE_MODEL, sr.getItem().getHardware()); |
6010 |
18 Sep 20 |
nicklas |
207 |
if (m != null) models.add(m); |
6010 |
18 Sep 20 |
nicklas |
208 |
} |
6010 |
18 Sep 20 |
nicklas |
209 |
return models; |
6010 |
18 Sep 20 |
nicklas |
210 |
} |
6010 |
18 Sep 20 |
nicklas |
211 |
|
6010 |
18 Sep 20 |
nicklas |
212 |
|
6010 |
18 Sep 20 |
nicklas |
213 |
/** |
5550 |
09 Aug 19 |
nicklas |
Get the read strings used to demux the data in the given demuxed sequences. |
5550 |
09 Aug 19 |
nicklas |
Typically the same read string is used for all data, but there are cases |
5550 |
09 Aug 19 |
nicklas |
that uses different read strings from different sources. |
5550 |
09 Aug 19 |
nicklas |
217 |
*/ |
5550 |
09 Aug 19 |
nicklas |
218 |
private Set<String> getReadStrings(CohortItem item, List<DemuxedSequences> demuxedSequences) |
5550 |
09 Aug 19 |
nicklas |
219 |
{ |
5550 |
09 Aug 19 |
nicklas |
220 |
Set<String> readStrings = new TreeSet<>(); |
5550 |
09 Aug 19 |
nicklas |
221 |
for (DemuxedSequences dx : demuxedSequences) |
5550 |
09 Aug 19 |
nicklas |
222 |
{ |
5861 |
11 Mar 20 |
nicklas |
223 |
String rs = (String)item.getAnnotationValue(Annotationtype.READ_STRING, dx.getItem()); |
5861 |
11 Mar 20 |
nicklas |
224 |
if (rs != null) readStrings.add(rs); |
5550 |
09 Aug 19 |
nicklas |
225 |
} |
5550 |
09 Aug 19 |
nicklas |
226 |
return readStrings; |
5550 |
09 Aug 19 |
nicklas |
227 |
} |
5550 |
09 Aug 19 |
nicklas |
228 |
|
5550 |
09 Aug 19 |
nicklas |
229 |
/** |
6010 |
18 Sep 20 |
nicklas |
Get the name of the software used in demuxing. A merged item **should** |
6010 |
18 Sep 20 |
nicklas |
have the same software for all DemuxedSequences. We do not check this |
6010 |
18 Sep 20 |
nicklas |
but return all names that we find. |
6010 |
18 Sep 20 |
nicklas |
@since 4.27.4 |
6010 |
18 Sep 20 |
nicklas |
234 |
*/ |
6010 |
18 Sep 20 |
nicklas |
235 |
private Set<String> getDemuxSoftwareNames(CohortItem item, List<DemuxedSequences> demuxedSequences) |
6010 |
18 Sep 20 |
nicklas |
236 |
{ |
6010 |
18 Sep 20 |
nicklas |
237 |
Set<String> softwareNames = new TreeSet<>(); |
6010 |
18 Sep 20 |
nicklas |
238 |
for (DemuxedSequences dx : demuxedSequences) |
6010 |
18 Sep 20 |
nicklas |
239 |
{ |
6010 |
18 Sep 20 |
nicklas |
240 |
String software = getName(dx.getItem().getSoftware()); |
6010 |
18 Sep 20 |
nicklas |
241 |
if (software != null) softwareNames.add(software); |
6010 |
18 Sep 20 |
nicklas |
242 |
} |
6010 |
18 Sep 20 |
nicklas |
243 |
return softwareNames; |
6010 |
18 Sep 20 |
nicklas |
244 |
} |
6010 |
18 Sep 20 |
nicklas |
245 |
|
6010 |
18 Sep 20 |
nicklas |
246 |
/** |
5550 |
09 Aug 19 |
nicklas |
Get the pool names that overlap between the given list of pools (expected to be pools from |
5550 |
09 Aug 19 |
nicklas |
the same library) and the pools that was sequenced in the given sequencing runs. |
5550 |
09 Aug 19 |
nicklas |
249 |
*/ |
5550 |
09 Aug 19 |
nicklas |
250 |
private Set<String> getSequencedPoolNames(CohortItem item, List<DemuxedSequences> demuxedSequences, List<PooledLibrary> pools) |
5550 |
09 Aug 19 |
nicklas |
251 |
{ |
5550 |
09 Aug 19 |
nicklas |
252 |
Set<String> poolNames = new HashSet<>(); |
5550 |
09 Aug 19 |
nicklas |
253 |
for (PooledLibrary pool : pools) |
5550 |
09 Aug 19 |
nicklas |
254 |
{ |
5550 |
09 Aug 19 |
nicklas |
255 |
poolNames.add(pool.getName()); |
5550 |
09 Aug 19 |
nicklas |
256 |
} |
5550 |
09 Aug 19 |
nicklas |
257 |
|
5550 |
09 Aug 19 |
nicklas |
258 |
Set<String> sequencedPools = new TreeSet<String>(); |
5550 |
09 Aug 19 |
nicklas |
259 |
for (DemuxedSequences dx : demuxedSequences) |
5550 |
09 Aug 19 |
nicklas |
260 |
{ |
5550 |
09 Aug 19 |
nicklas |
261 |
for (PooledLibrary p : item.getPools(dx)) |
5550 |
09 Aug 19 |
nicklas |
262 |
{ |
5550 |
09 Aug 19 |
nicklas |
263 |
if (poolNames.contains(p.getName())) sequencedPools.add(p.getName()); |
5550 |
09 Aug 19 |
nicklas |
264 |
} |
5550 |
09 Aug 19 |
nicklas |
265 |
} |
5550 |
09 Aug 19 |
nicklas |
266 |
return sequencedPools; |
5550 |
09 Aug 19 |
nicklas |
267 |
} |
5550 |
09 Aug 19 |
nicklas |
268 |
|
4402 |
17 Mar 17 |
nicklas |
269 |
@Override |
4469 |
26 Apr 17 |
nicklas |
270 |
public List<CohortTypeDef> getTypeDefsInJSON() |
4402 |
17 Mar 17 |
nicklas |
271 |
{ |
4469 |
26 Apr 17 |
nicklas |
272 |
DbControl dc = getDbControl(); |
4407 |
20 Mar 17 |
nicklas |
273 |
|
4469 |
26 Apr 17 |
nicklas |
274 |
CohortTypeDefFactory mergedFactory = new CohortTypeDefFactory(dc, Item.DERIVEDBIOASSAY, "MergedSequences"); |
4407 |
20 Mar 17 |
nicklas |
275 |
|
5550 |
09 Aug 19 |
nicklas |
276 |
mergedFactory.createAnnotationType(Annotationtype.PIPELINE); |
4472 |
27 Apr 17 |
nicklas |
277 |
mergedFactory.createAnnotationType(Annotationtype.PF_READS); |
4472 |
27 Apr 17 |
nicklas |
278 |
mergedFactory.createAnnotationType(Annotationtype.PT_READS); |
4472 |
27 Apr 17 |
nicklas |
279 |
mergedFactory.createAnnotationType(Annotationtype.ADAPTER_READS); |
4472 |
27 Apr 17 |
nicklas |
280 |
|
4472 |
27 Apr 17 |
nicklas |
281 |
mergedFactory.createAnnotationType(Annotationtype.FRAGMENT_SIZE_AVG); |
4472 |
27 Apr 17 |
nicklas |
282 |
mergedFactory.createAnnotationType(Annotationtype.FRAGMENT_SIZE_STDEV); |
6424 |
28 Sep 21 |
nicklas |
283 |
mergedFactory.createAnnotationType(Annotationtype.READLENGTH_AVG_R1); |
6424 |
28 Sep 21 |
nicklas |
284 |
mergedFactory.createAnnotationType(Annotationtype.READLENGTH_AVG_R2); |
4472 |
27 Apr 17 |
nicklas |
285 |
|
4469 |
26 Apr 17 |
nicklas |
286 |
mergedFactory.createAnnotationType(Annotationtype.DATA_FILES_FOLDER).setProjectSpecificValues(true); |
4469 |
26 Apr 17 |
nicklas |
287 |
mergedFactory.createFileType(Datafiletype.FASTQ); |
4469 |
26 Apr 17 |
nicklas |
288 |
|
6010 |
18 Sep 20 |
nicklas |
289 |
mergedFactory.createAnnotationType("DemuxSoftware", Type.STRING); |
4472 |
27 Apr 17 |
nicklas |
290 |
mergedFactory.createAnnotationType("PoolName", Type.STRING); |
6010 |
18 Sep 20 |
nicklas |
291 |
mergedFactory.createAnnotationType("SequencerModel", Type.STRING); // Annotationtype.HARDWARE_MODEL |
4472 |
27 Apr 17 |
nicklas |
292 |
mergedFactory.createAnnotationType("SequencerSerial", Type.STRING); |
4472 |
27 Apr 17 |
nicklas |
293 |
mergedFactory.createAnnotationType("ReadString", Type.STRING); |
4472 |
27 Apr 17 |
nicklas |
294 |
|
4469 |
26 Apr 17 |
nicklas |
295 |
return mergedFactory.allCreated(); |
4402 |
17 Mar 17 |
nicklas |
296 |
} |
4402 |
17 Mar 17 |
nicklas |
297 |
|
4402 |
17 Mar 17 |
nicklas |
298 |
|
3936 |
16 May 16 |
nicklas |
299 |
} |