-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
297 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
lts/carbon | ||
lts/erbium |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<script> | ||
/** | ||
* Show a "scroll through a list of regions" toolbar | ||
*/ | ||
export default { | ||
name: 'BatchScroller', | ||
props: ['regions'], | ||
data() { | ||
return { current_index: null }; | ||
}, | ||
methods: { | ||
cancelNavigation() { | ||
this.$emit('cancel'); | ||
}, | ||
goToItem(increment) { | ||
if (this.current_index === null) { | ||
this.current_index = 0; | ||
} else { | ||
this.current_index += increment; | ||
} | ||
this.$emit('navigate', this.current_region); | ||
}, | ||
}, | ||
computed: { | ||
current_region() { | ||
return this.current_index === null ? null : this.regions[this.current_index]; | ||
}, | ||
current_region_display() { | ||
const region = this.current_region; | ||
if (!region) { | ||
return '(none)'; | ||
} | ||
const { chr, start, end } = region; | ||
return `${chr}: ${start.toLocaleString()}-${end.toLocaleString()}`; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
|
||
<template> | ||
<div class="alert-success d-flex justify-content-between align-items-center"> | ||
<button class="btn btn-link" | ||
@click="goToItem(-1)" | ||
:disabled="this.current_index <= 0" | ||
>< Prev</button> | ||
<span> | ||
Current Locus: {{current_region_display}} - | ||
<span v-if="this.current_index !==null"> | ||
({{this.current_index + 1}} of {{this.regions.length}}) - | ||
</span> | ||
<button @click="cancelNavigation" | ||
class="btn btn-link p-0 border-0 align-bottom" | ||
title="Cancel navigation" | ||
>cancel batch mode</button> | ||
</span> | ||
<button class="btn btn-link" | ||
@click="goToItem(+1)" | ||
:disabled="this.current_index !== null && this.current_index >= this.regions.length - 1" | ||
>Next ></button> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<script> | ||
/** | ||
* Allows user to designate a list of regions to plot. Handles parsing and selection of regions, | ||
* which will then be consumed by another widget that handles cycling between those choices. | ||
*/ | ||
import { BDropdown } from 'bootstrap-vue/esm/'; | ||
import { parseRegion } from '../util/entity-helpers'; | ||
export default { | ||
name: 'BatchSpec', | ||
props: { max_range: Number }, | ||
data() { | ||
return { | ||
region_text: '', | ||
show_loader: false, | ||
message: null, // display validation errors | ||
}; | ||
}, | ||
methods: { | ||
getRegionsFromTextBox() { | ||
// Regions are one per line, and eliminate empty lines | ||
const text = this.region_text.trim().split(/\r?\n/).filter(value => !!value); | ||
return text.map(item => parseRegion(item, { region_size: this.max_range })); | ||
}, | ||
validateRegions(items) { | ||
// There must be at least one region selected. Can add other checks in the future. | ||
return !!items.length; | ||
}, | ||
updateRegions(content) { // List of [chr,start, end] entries, one per region | ||
// Receive a list of regions, and store them in the textbox | ||
// Sometimes we may want to handle fetching items from a network request; wrap in a | ||
// promise to be sure this handles async behavior or values, consistently | ||
this.show_loader = true; | ||
Promise.resolve(content) | ||
.then(items => items.map(({ chr, start, end }) => `${chr}:${start}-${end}`).join('\n')) | ||
.then((result) => { this.region_text = result; }) | ||
.catch((e) => { this.message = 'Unable to retrieve items'; }) | ||
.finally(() => { this.show_loader = false; }); | ||
}, | ||
sendRegions() { | ||
// Fetch, parse, and send the list of regions | ||
let items; | ||
try { | ||
items = this.getRegionsFromTextBox(); | ||
} catch (e) { | ||
this.message = e.toString(); | ||
return; | ||
} | ||
if (!items.length) { | ||
this.message = 'Must specify at least one region'; | ||
return; | ||
} | ||
this.message = ''; | ||
this.$emit('ready', items); | ||
this.$refs.dropdown.hide(); | ||
}, | ||
}, | ||
components: { BDropdown }, | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<b-dropdown ref="dropdown" text="Batch view" variant="info"> | ||
<div class="px-3"> | ||
<label for="batch-region-list">Specify regions to plot (one per line):</label> | ||
<textarea id="batch-region-list" v-model="region_text" | ||
rows="10" placeholder="chr:start-end or chr:pos"></textarea> | ||
<div v-if="message" class="text-danger">{{message}}</div> | ||
<div class="d-flex justify-content-end"> | ||
<div v-if="show_loader" class="spinner-border text-warning" role="status"> | ||
<span class="sr-only">Loading...</span> | ||
</div> | ||
<!-- Optional spot for a button (like "fetch presets") --> | ||
<slot name="preset-button" :updateRegions="updateRegions"></slot> | ||
<button @click="sendRegions" class="btn btn-success ml-1">Go</button> | ||
</div> | ||
</div> | ||
</b-dropdown> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
const PORTAL_API_BASE_URL = 'https://portaldev.sph.umich.edu/api/v1/'; | ||
const PORTAL_DEV_API_BASE_URL = 'https://portaldev.sph.umich.edu/api_internal_dev/v1/'; | ||
const LD_SERVER_BASE_URL = 'https://portaldev.sph.umich.edu/ld/'; | ||
|
||
const REGEX_REGION = /(?:chr)?(.+):(\d+)-(\d+)/; | ||
const REGEX_POSITION = /(?:chr)?(\w+)\s*:\s*(\d+)/; | ||
const REGEX_REGION = /(?:chr)?(\w+)\s*:\s*(\d+)-(\d+)/; | ||
|
||
|
||
export { | ||
REGEX_REGION, | ||
PORTAL_API_BASE_URL, PORTAL_DEV_API_BASE_URL, LD_SERVER_BASE_URL, | ||
REGEX_REGION, REGEX_POSITION, | ||
PORTAL_API_BASE_URL, LD_SERVER_BASE_URL, | ||
}; |
Oops, something went wrong.