6204 |
09 Apr 21 |
nicklas |
1 |
package net.sf.basedb.reggie.plugins.cmd; |
6204 |
09 Apr 21 |
nicklas |
2 |
|
6204 |
09 Apr 21 |
nicklas |
3 |
import java.util.List; |
6204 |
09 Apr 21 |
nicklas |
4 |
|
6204 |
09 Apr 21 |
nicklas |
5 |
import net.sf.basedb.core.DbControl; |
6204 |
09 Apr 21 |
nicklas |
6 |
import net.sf.basedb.core.ItemQuery; |
6204 |
09 Apr 21 |
nicklas |
7 |
import net.sf.basedb.core.Software; |
6204 |
09 Apr 21 |
nicklas |
8 |
import net.sf.basedb.core.query.Annotations; |
6204 |
09 Apr 21 |
nicklas |
9 |
import net.sf.basedb.core.query.Expressions; |
6204 |
09 Apr 21 |
nicklas |
10 |
import net.sf.basedb.core.query.Hql; |
6204 |
09 Apr 21 |
nicklas |
11 |
import net.sf.basedb.core.query.Restrictions; |
6204 |
09 Apr 21 |
nicklas |
12 |
import net.sf.basedb.reggie.Reggie; |
6204 |
09 Apr 21 |
nicklas |
13 |
import net.sf.basedb.reggie.dao.Annotationtype; |
6204 |
09 Apr 21 |
nicklas |
14 |
import net.sf.basedb.reggie.dao.Pipeline; |
6204 |
09 Apr 21 |
nicklas |
15 |
import net.sf.basedb.reggie.dao.Subtype; |
6204 |
09 Apr 21 |
nicklas |
16 |
|
6204 |
09 Apr 21 |
nicklas |
17 |
/** |
6204 |
09 Apr 21 |
nicklas |
Holds all information about a demux. Validation will |
6204 |
09 Apr 21 |
nicklas |
be done at construction and errors are reported to |
6204 |
09 Apr 21 |
nicklas |
the JsonSection. Check the 'valid' flag before using |
6204 |
09 Apr 21 |
nicklas |
the information. |
6204 |
09 Apr 21 |
nicklas |
22 |
|
6204 |
09 Apr 21 |
nicklas |
@since 4.32 |
6204 |
09 Apr 21 |
nicklas |
24 |
*/ |
6204 |
09 Apr 21 |
nicklas |
25 |
public class DemuxInfo |
6204 |
09 Apr 21 |
nicklas |
26 |
{ |
6204 |
09 Apr 21 |
nicklas |
27 |
|
6204 |
09 Apr 21 |
nicklas |
28 |
public Software software; |
6204 |
09 Apr 21 |
nicklas |
29 |
public String readString; |
6215 |
16 Apr 21 |
nicklas |
30 |
public Long pfReads; |
6215 |
16 Apr 21 |
nicklas |
31 |
public Long reads; |
6204 |
09 Apr 21 |
nicklas |
32 |
|
6215 |
16 Apr 21 |
nicklas |
33 |
public boolean valid = false; |
6215 |
16 Apr 21 |
nicklas |
34 |
|
6893 |
25 Nov 22 |
nicklas |
35 |
public DemuxInfo(JsonSection demuxSection, JsonSection mergeSection, MainInfo main) |
6204 |
09 Apr 21 |
nicklas |
36 |
{ |
6215 |
16 Apr 21 |
nicklas |
37 |
if (demuxSection != null && mergeSection != null) |
6204 |
09 Apr 21 |
nicklas |
38 |
{ |
6215 |
16 Apr 21 |
nicklas |
39 |
software = demuxSection.getRequiredEntry("Software", SoftwareValidator.INSTANCE); |
6215 |
16 Apr 21 |
nicklas |
40 |
readString = demuxSection.getRequiredEntry("ReadString", PatternValidator.READ_STRING); |
7286 |
15 Aug 23 |
nicklas |
41 |
pfReads = mergeSection.getRequiredEntry("PF_READS", LongValidator.POSITIVE.warnIf(20000000l, 75000000l)); // Warn if less than 20M or more than 75M reads |
6215 |
16 Apr 21 |
nicklas |
42 |
reads = pfReads; // |
6215 |
16 Apr 21 |
nicklas |
43 |
valid = !demuxSection.hasError() && !mergeSection.hasError(); |
6204 |
09 Apr 21 |
nicklas |
44 |
} |
6204 |
09 Apr 21 |
nicklas |
45 |
} |
6204 |
09 Apr 21 |
nicklas |
46 |
|
6204 |
09 Apr 21 |
nicklas |
47 |
/** |
6204 |
09 Apr 21 |
nicklas |
Find a Demuxing software with ExternalRef given from the JSON file and |
6204 |
09 Apr 21 |
nicklas |
Pipeline=RNAseq. |
6204 |
09 Apr 21 |
nicklas |
50 |
*/ |
6204 |
09 Apr 21 |
nicklas |
51 |
static class SoftwareValidator |
6204 |
09 Apr 21 |
nicklas |
52 |
implements ValueValidator<String, Software> |
6204 |
09 Apr 21 |
nicklas |
53 |
{ |
6204 |
09 Apr 21 |
nicklas |
54 |
|
6204 |
09 Apr 21 |
nicklas |
55 |
static final SoftwareValidator INSTANCE = new SoftwareValidator(); |
6204 |
09 Apr 21 |
nicklas |
56 |
|
6204 |
09 Apr 21 |
nicklas |
57 |
@Override |
6204 |
09 Apr 21 |
nicklas |
58 |
public Class<String> getExpectedClass() |
6204 |
09 Apr 21 |
nicklas |
59 |
{ |
6204 |
09 Apr 21 |
nicklas |
60 |
return String.class; |
6204 |
09 Apr 21 |
nicklas |
61 |
} |
6204 |
09 Apr 21 |
nicklas |
62 |
|
6204 |
09 Apr 21 |
nicklas |
63 |
@Override |
6204 |
09 Apr 21 |
nicklas |
64 |
public Software isValid(DbControl dc, String value, JsonSection section, String entryKey) |
6204 |
09 Apr 21 |
nicklas |
65 |
{ |
6204 |
09 Apr 21 |
nicklas |
66 |
ItemQuery<Software> query = Software.getQuery(); |
6204 |
09 Apr 21 |
nicklas |
67 |
query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); |
6204 |
09 Apr 21 |
nicklas |
68 |
Subtype.DEMUX_SOFTWARE.addFilter(dc, query); |
6204 |
09 Apr 21 |
nicklas |
69 |
Pipeline.RNA_SEQ.addFilter(dc, query); |
6204 |
09 Apr 21 |
nicklas |
70 |
query.join(Annotations.innerJoin(Annotationtype.EXTERNAL_REF.get(dc), "ref")); |
6204 |
09 Apr 21 |
nicklas |
71 |
query.restrict(Restrictions.eq(Hql.alias("ref"), Expressions.string(value))); |
6204 |
09 Apr 21 |
nicklas |
72 |
List<Software> list = query.list(dc); |
6204 |
09 Apr 21 |
nicklas |
73 |
if (list.size() != 1) |
6204 |
09 Apr 21 |
nicklas |
74 |
{ |
6204 |
09 Apr 21 |
nicklas |
75 |
if (list.size() > 1) |
6204 |
09 Apr 21 |
nicklas |
76 |
{ |
6240 |
19 May 21 |
nicklas |
77 |
section.addErrorMessage("Found "+list.size()+" demux software: ExternalRef="+value); |
6204 |
09 Apr 21 |
nicklas |
78 |
} |
6204 |
09 Apr 21 |
nicklas |
79 |
else |
6204 |
09 Apr 21 |
nicklas |
80 |
{ |
6240 |
19 May 21 |
nicklas |
81 |
section.addErrorMessage("Demux software not found: ExternalRef="+value); |
6204 |
09 Apr 21 |
nicklas |
82 |
} |
6204 |
09 Apr 21 |
nicklas |
83 |
return null; |
6204 |
09 Apr 21 |
nicklas |
84 |
} |
6204 |
09 Apr 21 |
nicklas |
85 |
return list.get(0); |
6204 |
09 Apr 21 |
nicklas |
86 |
} |
6204 |
09 Apr 21 |
nicklas |
87 |
} |
6204 |
09 Apr 21 |
nicklas |
88 |
|
6204 |
09 Apr 21 |
nicklas |
89 |
} |