Skip to content

Commit 3f3d830

Browse files
committed
Provide a functional JB2 session config, useful to demos and integration testing
1 parent d409f7b commit 3f3d830

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"configuration": {},
3+
"assemblies": [
4+
{
5+
"name": "hg38",
6+
"aliases": ["GRCh38"],
7+
"sequence": {
8+
"type": "ReferenceSequenceTrack",
9+
"trackId": "P6R5xbRqRr",
10+
"adapter": {
11+
"type": "BgzipFastaAdapter",
12+
"fastaLocation": {
13+
"uri": "https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz"
14+
},
15+
"faiLocation": {
16+
"uri": "https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz.fai"
17+
},
18+
"gziLocation": {
19+
"uri": "https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz.gzi"
20+
}
21+
}
22+
},
23+
"refNameAliases": {
24+
"adapter": {
25+
"type": "RefNameAliasAdapter",
26+
"location": {
27+
"uri": "https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/hg38_aliases.txt"
28+
}
29+
}
30+
}
31+
}
32+
],
33+
"tracks": [
34+
{
35+
"type": "VariantTrack",
36+
"trackId": "clinvar_ncbi_hg38",
37+
"name": "ClinVar variants (NCBI)",
38+
"assemblyNames": ["hg38"],
39+
"category": ["Annotation"],
40+
"adapter": {
41+
"type": "VcfTabixAdapter",
42+
"vcfGzLocation": {
43+
"uri": "https://ftp.ncbi.nlm.nih.gov/pub/clinvar/vcf_GRCh38/clinvar.vcf.gz"
44+
},
45+
"index": {
46+
"location": {
47+
"uri": "https://ftp.ncbi.nlm.nih.gov/pub/clinvar/vcf_GRCh38/clinvar.vcf.gz.tbi"
48+
}
49+
}
50+
}
51+
},
52+
{
53+
"type": "FeatureTrack",
54+
"trackId": "ncbi_refseq_109_hg38_latest",
55+
"name": "NCBI RefSeq (GFF3Tabix)",
56+
"assemblyNames": ["hg38"],
57+
"category": ["Annotation"],
58+
"adapter": {
59+
"type": "Gff3TabixAdapter",
60+
"gffGzLocation": {
61+
"uri": "https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/ncbi_refseq/GRCh38_latest_genomic.sort.gff.gz"
62+
},
63+
"index": {
64+
"location": {
65+
"uri": "https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/ncbi_refseq/GRCh38_latest_genomic.sort.gff.gz.tbi"
66+
}
67+
}
68+
}
69+
}
70+
],
71+
"connections": [],
72+
"defaultSession": {
73+
"name": "New Session"
74+
}
75+
}

jbrowse/src/org/labkey/jbrowse/JBrowseController.java

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import htsjdk.variant.variantcontext.Genotype;
2121
import htsjdk.variant.variantcontext.VariantContext;
2222
import htsjdk.variant.vcf.VCFFileReader;
23+
import org.apache.commons.io.IOUtils;
2324
import org.apache.commons.lang3.StringUtils;
2425
import org.jetbrains.annotations.NotNull;
2526
import org.json.JSONArray;
@@ -45,12 +46,15 @@
4546
import org.labkey.api.data.TableInfo;
4647
import org.labkey.api.data.TableSelector;
4748
import org.labkey.api.exp.api.ExpData;
49+
import org.labkey.api.module.Module;
50+
import org.labkey.api.module.ModuleLoader;
4851
import org.labkey.api.pipeline.PipeRoot;
4952
import org.labkey.api.pipeline.PipelineService;
5053
import org.labkey.api.pipeline.PipelineValidationException;
5154
import org.labkey.api.query.FieldKey;
5255
import org.labkey.api.query.QueryService;
5356
import org.labkey.api.query.UserSchema;
57+
import org.labkey.api.resource.FileResource;
5458
import org.labkey.api.security.RequiresPermission;
5559
import org.labkey.api.security.permissions.AdminOperationsPermission;
5660
import org.labkey.api.security.permissions.AdminPermission;
@@ -59,6 +63,7 @@
5963
import org.labkey.api.security.permissions.UpdatePermission;
6064
import org.labkey.api.util.ExceptionUtil;
6165
import org.labkey.api.util.PageFlowUtil;
66+
import org.labkey.api.util.Path;
6267
import org.labkey.api.view.JspView;
6368
import org.labkey.api.view.NavTree;
6469
import org.labkey.api.view.UnauthorizedException;
@@ -67,11 +72,17 @@
6772
import org.labkey.jbrowse.model.Database;
6873
import org.labkey.jbrowse.model.JsonFile;
6974
import org.labkey.jbrowse.pipeline.JBrowseSessionPipelineJob;
75+
import org.labkey.sequenceanalysis.SequenceAnalysisModule;
7076
import org.springframework.validation.BindException;
7177
import org.springframework.validation.Errors;
7278
import org.springframework.web.servlet.ModelAndView;
7379

80+
import java.io.File;
81+
import java.io.FileInputStream;
82+
import java.io.FileNotFoundException;
7483
import java.io.IOException;
84+
import java.io.InputStream;
85+
import java.nio.charset.StandardCharsets;
7586
import java.sql.SQLException;
7687
import java.util.ArrayList;
7788
import java.util.Arrays;
@@ -704,4 +715,63 @@ public void setStop(Integer stop)
704715
_stop = stop;
705716
}
706717
}
718+
719+
@RequiresPermission(ReadPermission.class)
720+
public class GetSessionAction extends ReadOnlyApiAction<GetSessionForm>
721+
{
722+
private static final String DEMO = "demo";
723+
724+
@Override
725+
public void validateForm(GetSessionForm form, Errors errors)
726+
{
727+
if (StringUtils.isEmpty(form.getSession()))
728+
{
729+
errors.reject(ERROR_MSG, "Must provide the session Id");
730+
}
731+
}
732+
733+
@Override
734+
public Object execute(GetSessionForm form, BindException errors) throws Exception
735+
{
736+
JSONObject resp;
737+
if (DEMO.equalsIgnoreCase(form.getSession()))
738+
{
739+
Module module = ModuleLoader.getInstance().getModule(JBrowseModule.class);
740+
FileResource r = (FileResource)module.getModuleResolver().lookup(Path.parse("external/minimalSession.json"));
741+
File jsonFile = r.getFile();
742+
if (jsonFile == null)
743+
{
744+
throw new FileNotFoundException("Unable to find JSON file: external/minimalSession.json");
745+
}
746+
747+
748+
try (InputStream is = new FileInputStream(jsonFile))
749+
{
750+
resp = new JSONObject(IOUtils.toString(is, StandardCharsets.UTF_8));
751+
}
752+
}
753+
else
754+
{
755+
resp = new JSONObject();
756+
resp.put("session", form.getSession());
757+
}
758+
759+
return new ApiSimpleResponse(resp);
760+
}
761+
}
762+
763+
public static class GetSessionForm
764+
{
765+
private String session;
766+
767+
public String getSession()
768+
{
769+
return session;
770+
}
771+
772+
public void setSession(String session)
773+
{
774+
this.session = session;
775+
}
776+
}
707777
}

0 commit comments

Comments
 (0)