Five hand-written GTF readers disagree on attribute parsing and malformed rows

Aperta
#192 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
data

Direzione di ricerca

Start by reading orfdata/gtf.py and the five reader loops named in the issue, along with the existing GTF tests. Compare their row validation, attribute parsing, and header handling, then check how PyEnsembl provides gtfparse. Done means the five readers use one shared reader and tests cover malformed rows and quoted attribute values consistently.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

ORFdata reads GTF files with five separate hand-written loops, each with its own attribute regex, row validation and header handling. They disagree on malformed input. A row without nine tab-separated fields is an error in three of them and is silently skipped in two. Attribute parsing uses three different patterns. A fix to any of them (for example the quote handling from #179) lands in one reader only. This is the GTF counterpart of #182 for FASTA. The stack's GTF reader, gtfparse, is already installed through PyEnsembl.

Evidence

Read at d8ab958.

Reader Rows read Attribute pattern Row with ≠ 9 fields
orfdata/gtf.py:145 read_exons (used by viral_installed.py:73) exon (\w+) "([^"]*)" (gtf.py:19) raises
orfdata/ensembl.py:69 _annotation transcript, CDS; reads #!genome-build-accession (\w+) "([^"]*)" raises
orfdata/sources/wang.py:115 _annotation all; reads #! headers (\w+) "([^\"]*)"; (needs the ;) raises
orfdata/sources/ncorf_mammals.py:61 _transcripts (also used by sources/riborf.py:135,201) exon (\S+) "([^"]*)" (ncorf_mammals.py:33) skipped (len(fields) < 9)
orfdata/sources/riborf_native.py:23 _annotations exon imports ncorf_mammals._ATTRIBUTE skipped (len(fields) != 9)

Each loop also opens the file itself: gzip.open in the three source modules, plain open in gtf.read_exons, and ensembl._source in ensembl.py.

Suggested fix

  • Add one public reader to orfdata/gtf.py. For example, read_gtf_rows(path, features=None) would yield (seqname, feature, start, end, strand, attributes) plus the #! header mapping, open plain or gzipped files, use one attribute parser (the inverse of gtf.attributes), and raise on malformed rows with path and line number. Alternatively, build it on gtfparse.read_gtf(..., features=...) and read the #! header lines separately.
  • Rewrite the five loops on top of it, keeping only their source-specific grouping and checks.
  • Add a test with one malformed row and one quoted attribute value that every caller must handle the same way.

https://claude.ai/code/session_01JHJhwj29oDqoeu7TYd34Pi

Lingua principale
Python
Stelle
1
Fork
1
Merge medio
10h 11m
PR unite (30g)
51

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openvax/orfdata

Tutte le issue di openvax/orfdata

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.