Skip to content

Commit

Permalink
Weird workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Nov 6, 2024
1 parent 9c925b7 commit 0605413
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
10 changes: 9 additions & 1 deletion plugins/bed/src/BigBedAdapter/BigBedAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Observer } from 'rxjs'
import {
isUcscProcessedTranscript,
ucscProcessedTranscript,
makeRepeatTrackDescription,
makeBlocks,
arrayify,
} from '../util'
Expand Down Expand Up @@ -154,6 +155,7 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
chrom,
chromStart,
chromEnd,
description,
chromStarts: chromStarts2,
blockStarts: blockStarts2,
blockSizes: blockSizes2,
Expand Down Expand Up @@ -184,6 +186,7 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
strand,
blockCount,
thickStart,
description,
})
) {
const f = ucscProcessedTranscript({
Expand All @@ -195,6 +198,7 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
end: feat.end,
refName: query.refName,
score,
description,
chromStarts: chromStarts!,
blockSizes: blockSizes!,
blockCount,
Expand All @@ -214,7 +218,10 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
)
) {
observer.next(
new SimpleFeature({ id: `${this.id}-${uniqueId}`, data: f }),
new SimpleFeature({
id: `${this.id}-${uniqueId}`,
data: f,
}),
)
}
}
Expand All @@ -232,6 +239,7 @@ export default class BigBedAdapter extends BaseFeatureDataAdapter {
id: `${this.id}-${uniqueId}`,
data: {
...rest,
...makeRepeatTrackDescription(description),
start: feat.start,
end: feat.end,
strand,
Expand Down
58 changes: 57 additions & 1 deletion plugins/bed/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface TranscriptFeat extends MinimalFeature {
subfeatures: MinimalFeature[]
}

const SPECIFIC_LENGTH_OF_REPEAT_MASKER_DESCRIPTION_FIELDS = 15

export function ucscProcessedTranscript(feature: TranscriptFeat) {
const {
subfeatures: oldSubfeatures,
Expand Down Expand Up @@ -219,6 +221,7 @@ export function featureData(
thickStart,
thickEnd,
type,
description,
strand: strand2,
score: score2,
chrom: _1,
Expand All @@ -243,6 +246,7 @@ export function featureData(

const f = {
...rest,
...makeRepeatTrackDescription(description),
type,
score,
start,
Expand All @@ -266,6 +270,7 @@ export function featureData(
strand,
blockCount,
thickStart,
description,
})
? ucscProcessedTranscript({
thickStart: thickStart!,
Expand All @@ -283,12 +288,20 @@ export function isUcscProcessedTranscript({
thickStart,
blockCount,
strand,
description,
}: {
thickStart?: number
blockCount?: number
strand?: number
description?: string
}) {
return thickStart && blockCount && strand !== 0
return (
thickStart &&
blockCount &&
strand !== 0 &&
description?.trim().split(' ').length !==
SPECIFIC_LENGTH_OF_REPEAT_MASKER_DESCRIPTION_FIELDS
)
}

export function arrayify(f?: string | number[]) {
Expand All @@ -298,3 +311,46 @@ export function arrayify(f?: string | number[]) {
: f
: undefined
}

export function makeRepeatTrackDescription(description?: string) {
if (
description?.trim().split(' ').length ===
SPECIFIC_LENGTH_OF_REPEAT_MASKER_DESCRIPTION_FIELDS
) {
const [
bitsw_score,
percent_div,
percent_del,
percent_ins,
query_chr,
query_begin,
query_end,
query_remaining,
orientation,
matching_repeat_name,
matching_repeat_class,
matching_repeat_begin,
matching_repeat_end,
matching_repeat_remaining,
repeat_id,
] = description.trim().split(' ')
return {
bitsw_score,
percent_div,
percent_del,
percent_ins,
query_chr,
query_begin,
query_end,
query_remaining,
orientation,
matching_repeat_name,
matching_repeat_class,
matching_repeat_begin,
matching_repeat_end,
matching_repeat_remaining,
repeat_id,
}
}
return { description }
}

0 comments on commit 0605413

Please sign in to comment.