6373 |
07 Sep 21 |
nicklas |
1 |
package net.sf.basedb.varsearch.index; |
6373 |
07 Sep 21 |
nicklas |
2 |
|
6528 |
20 Dec 21 |
nicklas |
3 |
import java.util.ArrayList; |
6373 |
07 Sep 21 |
nicklas |
4 |
import java.util.Collections; |
6373 |
07 Sep 21 |
nicklas |
5 |
import java.util.List; |
6373 |
07 Sep 21 |
nicklas |
6 |
|
6373 |
07 Sep 21 |
nicklas |
7 |
import org.slf4j.LoggerFactory; |
6373 |
07 Sep 21 |
nicklas |
8 |
|
6528 |
20 Dec 21 |
nicklas |
9 |
import net.sf.basedb.core.DataFileType; |
6373 |
07 Sep 21 |
nicklas |
10 |
import net.sf.basedb.core.DbControl; |
6373 |
07 Sep 21 |
nicklas |
11 |
import net.sf.basedb.core.File; |
6373 |
07 Sep 21 |
nicklas |
12 |
import net.sf.basedb.core.RawBioAssay; |
7074 |
24 Mar 23 |
nicklas |
13 |
import net.sf.basedb.util.extensions.logging.ExtensionsLog; |
7074 |
24 Mar 23 |
nicklas |
14 |
import net.sf.basedb.util.extensions.logging.ExtensionsLogger; |
6373 |
07 Sep 21 |
nicklas |
15 |
import net.sf.basedb.varsearch.dao.Datafiletype; |
7074 |
24 Mar 23 |
nicklas |
16 |
import net.sf.basedb.varsearch.service.VarSearchService; |
6373 |
07 Sep 21 |
nicklas |
17 |
|
6373 |
07 Sep 21 |
nicklas |
18 |
/** |
6373 |
07 Sep 21 |
nicklas |
VCF file locator implementation that find a single or multiple |
6373 |
07 Sep 21 |
nicklas |
files that are linked as data files of a given type. |
6373 |
07 Sep 21 |
nicklas |
@since 1.2 |
6373 |
07 Sep 21 |
nicklas |
22 |
*/ |
6373 |
07 Sep 21 |
nicklas |
23 |
public class DatafileVcfLocator |
6373 |
07 Sep 21 |
nicklas |
24 |
implements VcfFileLocator |
6373 |
07 Sep 21 |
nicklas |
25 |
{ |
6373 |
07 Sep 21 |
nicklas |
26 |
|
7074 |
24 Mar 23 |
nicklas |
27 |
private static final ExtensionsLogger logger = |
7074 |
24 Mar 23 |
nicklas |
28 |
ExtensionsLog.getLogger(VarSearchService.ID, true).wrap(LoggerFactory.getLogger(DatafileVcfLocator.class)); |
6373 |
07 Sep 21 |
nicklas |
29 |
|
6373 |
07 Sep 21 |
nicklas |
30 |
private final Datafiletype vcfFileType; |
6373 |
07 Sep 21 |
nicklas |
31 |
private final boolean multiple; |
6373 |
07 Sep 21 |
nicklas |
32 |
|
6373 |
07 Sep 21 |
nicklas |
33 |
public DatafileVcfLocator(Datafiletype vcfFileType, boolean multiple) |
6373 |
07 Sep 21 |
nicklas |
34 |
{ |
6373 |
07 Sep 21 |
nicklas |
35 |
this.vcfFileType = vcfFileType; |
6373 |
07 Sep 21 |
nicklas |
36 |
this.multiple = multiple; |
6373 |
07 Sep 21 |
nicklas |
37 |
} |
6373 |
07 Sep 21 |
nicklas |
38 |
|
6373 |
07 Sep 21 |
nicklas |
39 |
|
6373 |
07 Sep 21 |
nicklas |
40 |
@Override |
6528 |
20 Dec 21 |
nicklas |
41 |
public List<VcfFile> getVcfFiles(DbControl dc, RawBioAssay variantCall) |
6373 |
07 Sep 21 |
nicklas |
42 |
{ |
6528 |
20 Dec 21 |
nicklas |
43 |
List<VcfFile> vcfFiles = null; |
6528 |
20 Dec 21 |
nicklas |
44 |
DataFileType type = vcfFileType.get(dc); |
6373 |
07 Sep 21 |
nicklas |
45 |
if (multiple) |
6373 |
07 Sep 21 |
nicklas |
46 |
{ |
6528 |
20 Dec 21 |
nicklas |
47 |
vcfFiles = new ArrayList<>(); |
6528 |
20 Dec 21 |
nicklas |
48 |
for (File f : vcfFileType.getAllFiles(dc, variantCall)) |
6528 |
20 Dec 21 |
nicklas |
49 |
{ |
6528 |
20 Dec 21 |
nicklas |
50 |
vcfFiles.add(new VcfFile(f, type)); |
6528 |
20 Dec 21 |
nicklas |
51 |
} |
6373 |
07 Sep 21 |
nicklas |
52 |
} |
6373 |
07 Sep 21 |
nicklas |
53 |
else |
6373 |
07 Sep 21 |
nicklas |
54 |
{ |
6373 |
07 Sep 21 |
nicklas |
55 |
File vcfFile = vcfFileType.getFile(dc, variantCall); |
6528 |
20 Dec 21 |
nicklas |
56 |
vcfFiles = vcfFile == null ? Collections.emptyList() : Collections.singletonList(new VcfFile(vcfFile, type)); |
6373 |
07 Sep 21 |
nicklas |
57 |
} |
6373 |
07 Sep 21 |
nicklas |
58 |
if (vcfFiles.size() == 0) |
6373 |
07 Sep 21 |
nicklas |
59 |
{ |
6373 |
07 Sep 21 |
nicklas |
60 |
logger.warn("No '" + vcfFileType.getName() + "' file found for rawbioassay: " + variantCall.getName()); |
6373 |
07 Sep 21 |
nicklas |
61 |
} |
6373 |
07 Sep 21 |
nicklas |
62 |
return vcfFiles; |
6373 |
07 Sep 21 |
nicklas |
63 |
} |
6373 |
07 Sep 21 |
nicklas |
64 |
|
6373 |
07 Sep 21 |
nicklas |
65 |
|
6373 |
07 Sep 21 |
nicklas |
66 |
|
6373 |
07 Sep 21 |
nicklas |
67 |
} |