Skip to content

Commit f3421f7

Browse files
cmdcolinclaude
andcommitted
Add TAF format documentation and improve code comments
- Add reference to TAF format documentation (ComparativeGenomicsToolkit/taffy) - Document row instruction types and their meaning - Add function documentation to parseRowInstructions - Improve class documentation for BgzipTaffyAdapter - Add block documentation for lowerBound function Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 1e6c167 commit f3421f7

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/BgzipTaffyAdapter/BgzipTaffyAdapter.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ interface TafFeature {
5050
seq: string
5151
}
5252

53-
// Binary search to find the index of the first element >= target
53+
/**
54+
* Binary search to find the index of the first element >= target
55+
*/
5456
function lowerBound<T>(arr: T[], target: number, getKey: (item: T) => number) {
5557
let lo = 0
5658
let hi = arr.length
@@ -65,6 +67,12 @@ function lowerBound<T>(arr: T[], target: number, getKey: (item: T) => number) {
6567
return lo
6668
}
6769

70+
/**
71+
* Adapter for TAF (Taffy Alignment Format) files compressed with BGZIP
72+
* Implements streaming parsing of TAF blocks into MAF features
73+
*
74+
* TAF Format: https://github.com/ComparativeGenomicsToolkit/taffy
75+
*/
6876
export default class BgzipTaffyAdapter extends BaseFeatureDataAdapter {
6977
public setupP?: Promise<SetupData>
7078

src/BgzipTaffyAdapter/rowInstructions.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
/**
2+
* TAF (Taffy Alignment Format) row instruction types
3+
* Reference: https://github.com/ComparativeGenomicsToolkit/taffy
4+
*
5+
* Instruction types:
6+
* 'i' - insert: add a new sequence row
7+
* 's' - substitute: replace coordinates of an existing row
8+
* 'd' - delete: remove a sequence row
9+
* 'g' - gap: add a fixed-length gap to sequence start
10+
* 'G' - gap substring: add variable-length gap from substring
11+
*/
12+
113
interface RowInsert {
214
type: 'i'
315
row: number
@@ -60,6 +72,10 @@ export function filterFirstLineInstructions(
6072
})
6173
}
6274

75+
/**
76+
* Parses TAF row instruction string into structured RowInstruction objects
77+
* Each instruction token sequence is parsed according to TAF format rules
78+
*/
6379
export function parseRowInstructions(meta: string) {
6480
const ret = meta.split(' ')
6581
const rows = [] as RowInstruction[]

0 commit comments

Comments
 (0)