Skip to content

Commit a2ac535

Browse files
committed
Updates
1 parent 961ae1e commit a2ac535

File tree

4 files changed

+103
-14
lines changed

4 files changed

+103
-14
lines changed

component_tests/cli-node18/run.mjs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,25 @@ ctgA\ttest\tgene\t5000\t6000\t.\t+\t.\tID=gene3;Name=TestGene3
162162

163163
// Create HTTP server to serve the gzipped file
164164
const server = createServer((req, res) => {
165+
console.log(`[SERVER] Received request: ${req.method} ${req.url}`)
165166
if (req.url === '/test.gff3.gz') {
166167
const stat = statSync(gzFile)
168+
console.log(`[SERVER] Serving file, size: ${stat.size} bytes`)
167169
res.writeHead(200, {
168170
'Content-Type': 'application/gzip',
169171
'Content-Length': stat.size,
170172
})
171-
createReadStream(gzFile).pipe(res)
173+
const fileStream = createReadStream(gzFile)
174+
fileStream.on('end', () => {
175+
console.log('[SERVER] File stream ended')
176+
})
177+
fileStream.on('error', err => {
178+
console.log('[SERVER] File stream error:', err)
179+
})
180+
fileStream.pipe(res)
181+
res.on('finish', () => {
182+
console.log('[SERVER] Response finished')
183+
})
172184
} else {
173185
res.writeHead(404)
174186
res.end('Not found')
@@ -182,13 +194,27 @@ ctgA\ttest\tgene\t5000\t6000\t.\t+\t.\tID=gene3;Name=TestGene3
182194
})
183195
const addr = server.address()
184196
const port = addr.port
197+
console.log(`[TEST] Server listening on port ${port}`)
185198

186199
const outDir = join(tmpDir, 'indexes')
187200

188201
// Run text-index command against the remote file
189-
run(
190-
`npx jbrowse text-index --file http://localhost:${port}/test.gff3.gz --out ${outDir} --quiet`,
191-
)
202+
console.log(`[TEST] Running text-index command...`)
203+
const cmd = `npx jbrowse text-index --file http://localhost:${port}/test.gff3.gz --out ${outDir} --quiet`
204+
console.log(`[TEST] Command: ${cmd}`)
205+
try {
206+
const result = execSync(cmd, {
207+
encoding: 'utf8',
208+
stdio: ['pipe', 'pipe', 'pipe'],
209+
timeout: 60000,
210+
})
211+
console.log(`[TEST] Command stdout: ${result}`)
212+
} catch (cmdErr) {
213+
console.log(`[TEST] Command stderr: ${cmdErr.stderr}`)
214+
console.log(`[TEST] Command stdout: ${cmdErr.stdout}`)
215+
throw cmdErr
216+
}
217+
console.log(`[TEST] Command completed`)
192218

193219
// Check that index files were created
194220
// The command creates .ix and .ixx files

packages/text-indexing-core/src/types/common.ts

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@ export async function getLocalOrRemoteStream({
5050
let receivedBytes = 0
5151

5252
if (isURL(file)) {
53+
console.error(`[DEBUG] Fetching remote file: ${file}`)
5354
const res = await fetch(file)
55+
console.error(`[DEBUG] Fetch response status: ${res.status}`)
5456
if (!res.ok) {
5557
throw new Error(
5658
`Failed to fetch ${file} status ${res.status} ${await res.text()}`,
5759
)
5860
}
5961
const totalBytes = +(res.headers.get('Content-Length') || 0)
62+
console.error(`[DEBUG] Content-Length: ${totalBytes}`)
6063
onStart(totalBytes)
6164

6265
const body = res.body
@@ -67,9 +70,20 @@ export async function getLocalOrRemoteStream({
6770

6871
body.on('data', chunk => {
6972
receivedBytes += chunk.length
73+
console.error(
74+
`[DEBUG] Received chunk: ${chunk.length} bytes, total: ${receivedBytes}`,
75+
)
7076
onUpdate(receivedBytes)
7177
})
7278

79+
body.on('end', () => {
80+
console.error(`[DEBUG] Body stream ended, total bytes: ${receivedBytes}`)
81+
})
82+
83+
body.on('error', err => {
84+
console.error(`[DEBUG] Body stream error:`, err)
85+
})
86+
7387
return body as unknown as Readable
7488
} else {
7589
// Handle file:// URLs by converting to local path
@@ -94,13 +108,33 @@ export function createReadlineInterface(
94108
stream: Readable,
95109
inLocation: string,
96110
): readline.Interface {
97-
const inputStream = /.b?gz$/.exec(inLocation)
98-
? stream.pipe(createGunzip())
99-
: stream
111+
console.error(`[DEBUG] createReadlineInterface: inLocation=${inLocation}`)
112+
const isGzipped = /.b?gz$/.exec(inLocation)
113+
console.error(`[DEBUG] Is gzipped: ${!!isGzipped}`)
100114

101-
return readline.createInterface({
115+
let inputStream: Readable
116+
if (isGzipped) {
117+
const gunzip = createGunzip()
118+
gunzip.on('error', err => {
119+
console.error(`[DEBUG] Gunzip error:`, err)
120+
})
121+
gunzip.on('end', () => {
122+
console.error(`[DEBUG] Gunzip stream ended`)
123+
})
124+
inputStream = stream.pipe(gunzip)
125+
} else {
126+
inputStream = stream
127+
}
128+
129+
const rl = readline.createInterface({
102130
input: inputStream,
103131
})
132+
133+
rl.on('close', () => {
134+
console.error(`[DEBUG] Readline interface closed`)
135+
})
136+
137+
return rl
104138
}
105139

106140
// Efficient attribute parsing for GFF3/VCF info fields

packages/text-indexing-core/src/types/gff3Adapter.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,35 @@ export async function* indexGff3({
2323
onUpdate: (progressBytes: number) => void
2424
}) {
2525
const { trackId } = config
26+
console.error(
27+
`[DEBUG] indexGff3 starting for trackId=${trackId}, inLocation=${inLocation}`,
28+
)
2629
const stream = await getLocalOrRemoteStream({
2730
file: inLocation,
2831
out: outDir,
2932
onStart,
3033
onUpdate,
3134
})
35+
console.error(`[DEBUG] Got stream, creating readline interface`)
3236

3337
const rl = createReadlineInterface(stream, inLocation)
3438
const excludeSet = new Set(featureTypesToExclude)
3539
const encodedTrackId = encodeURIComponent(trackId)
3640

41+
let lineCount = 0
42+
let yieldCount = 0
43+
console.error(`[DEBUG] Starting to read lines`)
3744
for await (const line of rl) {
45+
lineCount++
46+
if (lineCount <= 5 || lineCount % 100 === 0) {
47+
console.error(`[DEBUG] Read line ${lineCount}: ${line.slice(0, 50)}...`)
48+
}
3849
if (!line.trim()) {
3950
continue
4051
} else if (line.startsWith('#')) {
4152
continue
4253
} else if (line.startsWith('>')) {
54+
console.error(`[DEBUG] Found FASTA header, breaking at line ${lineCount}`)
4355
break
4456
}
4557

@@ -57,8 +69,12 @@ export async function* indexGff3({
5769
const record = `["${encodeURIComponent(locStr)}"|"${encodedTrackId}"|${encodedAttrs.join('|')}]`
5870
const uniqueAttrs = [...new Set(attrs)]
5971

72+
yieldCount++
6073
yield `${record} ${uniqueAttrs.join(' ')}\n`
6174
}
6275
}
6376
}
77+
console.error(
78+
`[DEBUG] indexGff3 finished: read ${lineCount} lines, yielded ${yieldCount} records`,
79+
)
6480
}

products/jbrowse-cli/src/commands/text-index/indexing-utils.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export async function runIxIxx({
2828
prefixSize?: number
2929
quiet?: boolean
3030
}): Promise<void> {
31+
console.error(`[DEBUG] runIxIxx starting: name=${name}`)
3132
const progressBar = new SingleBar(
3233
{ format: '{bar} Sorting and writing index...', etaBuffer: 2000 },
3334
Presets.shades_classic,
@@ -37,12 +38,13 @@ export async function runIxIxx({
3738
progressBar.start(1, 0)
3839
}
3940

40-
await ixIxxStream(
41-
readStream,
42-
path.join(outLocation, 'trix', `${name}.ix`),
43-
path.join(outLocation, 'trix', `${name}.ixx`),
44-
prefixSize,
45-
)
41+
const ixPath = path.join(outLocation, 'trix', `${name}.ix`)
42+
const ixxPath = path.join(outLocation, 'trix', `${name}.ixx`)
43+
console.error(`[DEBUG] Calling ixIxxStream: ix=${ixPath}, ixx=${ixxPath}`)
44+
45+
await ixIxxStream(readStream, ixPath, ixxPath, prefixSize)
46+
47+
console.error(`[DEBUG] ixIxxStream completed`)
4648

4749
if (!quiet) {
4850
progressBar.update(1)
@@ -146,6 +148,11 @@ export async function indexDriver({
146148
assemblyNames: string[]
147149
prefixSize?: number
148150
}): Promise<void> {
151+
console.error(
152+
`[DEBUG] indexDriver starting: name=${name}, outLocation=${outLocation}`,
153+
)
154+
console.error(`[DEBUG] trackConfigs count: ${trackConfigs.length}`)
155+
149156
const readStream = Readable.from(
150157
indexFiles({
151158
trackConfigs,
@@ -156,6 +163,8 @@ export async function indexDriver({
156163
}),
157164
)
158165

166+
console.error(`[DEBUG] Created readStream from indexFiles, calling runIxIxx`)
167+
159168
await runIxIxx({
160169
readStream,
161170
outLocation,
@@ -164,6 +173,8 @@ export async function indexDriver({
164173
quiet,
165174
})
166175

176+
console.error(`[DEBUG] runIxIxx completed, generating meta`)
177+
167178
await generateMeta({
168179
configs: trackConfigs,
169180
attributesToIndex: attributes,
@@ -172,6 +183,8 @@ export async function indexDriver({
172183
featureTypesToExclude: typesToExclude,
173184
assemblyNames,
174185
})
186+
187+
console.error(`[DEBUG] indexDriver completed`)
175188
}
176189

177190
export function prepareFileTrackConfigs(

0 commit comments

Comments
 (0)