Skip to content

Commit

Permalink
Merge pull request #1295 from alliance-genome/improve_jb2_buffer
Browse files Browse the repository at this point in the history
improving the buffer around genes when highlighting a variant
  • Loading branch information
scottcain authored Apr 3, 2024
2 parents 22e8b2f + fea5a7d commit cff3508
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/components/variant/VariantJBrowseLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const calculateHighlight = (location, type) => {
}
};


const LINK_BUFFER = 1.2;

const buildTrackList = (taxonid) => {
const tracks = [];
Expand All @@ -36,20 +36,25 @@ const buildAssembly = (taxonid) => {
return getSpecies(taxonid).jBrowseName.replace(' ', '_');
}

const buildLoc = (location) => {
const start = location.start || 0;
const end = location.end || 0
const linkLength = end - start;
if (linkLength === 0 ) { return; }
let bufferedMin = Math.round(start - (linkLength * LINK_BUFFER / 2.5));
bufferedMin = bufferedMin < 0 ? 0 : bufferedMin;
const bufferedMax = Math.round(end + (linkLength * LINK_BUFFER ));
return location.chromosome + ':' + bufferedMin + '..' + bufferedMax ;
}

const VariantJBrowseLink = ({children, location, type, geneSymbol, geneLocation, taxonid}) => {
return (
location ?
<ExternalLink
href={'/jbrowse2/?' + stringifyQuery({
/* data: `data/${species}`, */
tracklist: 'true',
loc: (geneLocation && geneLocation.start && geneLocation.end) ?
`${geneLocation.chromosome || location.chromosome}:${geneLocation.start || 0}..${geneLocation.end || 0}` :
geneSymbol,
/* tracks: ['Variants', 'Multiple-Variant Alleles', 'High Throughput Variants', 'All Genes', 'DNA'].join(','), */
loc: buildLoc(geneLocation || location ) ,
assembly: buildAssembly(taxonid),
/* loc: `${geneLocation.chromosome || location.chromosome}:${geneLocation.start || 0}..${geneLocation.end || 0}`, */
tracks: buildTrackList(taxonid),
highlight: calculateHighlight(location, type)
})}
Expand Down

0 comments on commit cff3508

Please sign in to comment.