Skip to content

Commit

Permalink
Temp commit to fix buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
dariober committed Sep 18, 2024
1 parent b01ad2a commit f46e7a5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/apollo-cli/src/commands/assembly/add-from-fasta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Indexes should be named <my.fasta.gz>.gzi and <my.fasta.gz>.fai unless options -
access.accessToken,
fai,
'text/x-fai',
true,
false,
)

const gziId = gziIsFileId
Expand All @@ -147,7 +147,7 @@ Indexes should be named <my.fasta.gz>.gzi and <my.fasta.gz>.fai unless options -
access.accessToken,
gzi,
'application/x-gzi',
true,
false,
)

body = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ export class FilesService {
})
const fileName = join(fileUploadFolder, file.checksum)
switch (file.type) {
case 'application/x-bgzip-fasta':
case 'text/x-fai':
case 'application/x-gzi': {
return new LocalFileGzip(fileName)
}
case 'application/x-bgzip-fasta':
case 'text/x-gff3':
case 'text/x-fasta':
case 'text/x-fai': {
case 'text/x-fasta': {
return new LocalFile(fileName)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Model } from 'mongoose'
import { AssembliesService } from '../assemblies/assemblies.service'
import { GetSequenceDto } from './dto/get-sequence.dto'
import path from 'node:path'
import { LocalFileGzip } from '@apollo-annotation/shared'

@Injectable()
export class SequenceService {
Expand Down Expand Up @@ -96,7 +97,9 @@ export class SequenceService {
const sequenceAdapter = gzi
? new BgzipIndexedFasta({
fasta: new LocalFile(path.join(FILE_UPLOAD_FOLDER, faChecksum)),
fai: new LocalFile(path.join(FILE_UPLOAD_FOLDER, faiChecksum)),
fai: new LocalFileGzip(path.join(FILE_UPLOAD_FOLDER, faiChecksum), {
encoding: 'utf8',
}),
gzi: new LocalFile(path.join(FILE_UPLOAD_FOLDER, gziChecksum)),
})
: new IndexedFasta({
Expand Down
11 changes: 8 additions & 3 deletions packages/apollo-shared/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ export class LocalFileGzip implements GenericFilehandle {
): Promise<{ bytesRead: number; buffer: Buffer }> {
const fileHandle = await this.getFileHandle()
const unzippedContents = await unzip(fileHandle)
const str = unzippedContents.toString()
const substr = str.slice(position, position + length)
const bytesRead = buffer.write(substr, offset)
const bytesRead = unzippedContents.copy(
buffer,
position,
offset,
offset + length,
)
return { bytesRead, buffer }
}

Expand All @@ -59,8 +62,10 @@ export class LocalFileGzip implements GenericFilehandle {
const fileHandle = await this.getFileHandle()
const unzippedContents = await unzip(fileHandle)
if (this.opts.encoding) {
console.log(`IN: ${this.filename}`)

Check warning on line 65 in packages/apollo-shared/src/util.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement

Check warning on line 65 in packages/apollo-shared/src/util.ts

View workflow job for this annotation

GitHub Actions / Strict lint and test

Unexpected console statement
return unzippedContents.toString(this.opts.encoding)
}
console.log(`OUT: ${this.filename}`)

Check warning on line 68 in packages/apollo-shared/src/util.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement

Check warning on line 68 in packages/apollo-shared/src/util.ts

View workflow job for this annotation

GitHub Actions / Strict lint and test

Unexpected console statement
return unzippedContents
}

Expand Down

0 comments on commit f46e7a5

Please sign in to comment.