Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mashmap PAF support #2670

Merged
merged 2 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const DotplotImportForm = observer(({ model }: { model: DotplotViewModel }) => {
</a>{' '}
file for the dotplot view. Note that the first assembly should be
the left column of the PAF and the second assembly should be the
right column
right column. PAF-like files from MashMap (.out) are also allowed
</p>
<Grid container justifyContent="center">
<Grid item>
Expand Down
21 changes: 12 additions & 9 deletions plugins/dotplot-view/src/PAFAdapter/PAFAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ export default class PAFAdapter extends BaseFeatureDataAdapter {
encoding: 'utf8',
...opts,
})
const pafRecords: PafRecord[] = []
text.split('\n').forEach((line: string, index: number) => {
if (line.length) {

// mashmap produces PAF-like data that is space separated instead of tab
const hasTab = text.indexOf('\t')
const splitChar = hasTab !== -1 ? '\t' : ' '
return text
.split('\n')
.filter(line => !!line)
.map(line => {
const [
chr1,
,
Expand All @@ -78,7 +83,7 @@ export default class PAFAdapter extends BaseFeatureDataAdapter {
blockLen,
mappingQual,
...fields
] = line.split('\t')
] = line.split(splitChar)

const rest = Object.fromEntries(
fields.map(field => {
Expand All @@ -89,7 +94,7 @@ export default class PAFAdapter extends BaseFeatureDataAdapter {
}),
)

pafRecords[index] = {
return {
records: [
{ refName: chr1, start: +start1, end: +end1 },
{ refName: chr2, start: +start2, end: +end2 },
Expand All @@ -101,10 +106,8 @@ export default class PAFAdapter extends BaseFeatureDataAdapter {
mappingQual: +mappingQual,
...rest,
},
}
}
})
return pafRecords
} as PafRecord
})
}

async hasDataForRefName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ const ImportForm = observer(({ model }: { model: LinearSyntenyViewModel }) => {
</a>{' '}
file for the linear synteny view. Note that the first assembly
should be the left column of the PAF and the second assembly should
be the right column
be the right column. PAF-like files from MashMap (.out) are also
allowed
</Typography>
<Grid item>
<FileSelector
Expand Down