Détails de snippet
Parseur de fichier gff3 basique[Python]

{ numéro de l'ORF : [start, stop, strand ], ... }
Les print en commentaire permettent d'afficher le contenue du gff3 sur le terminal
contentGFF = ["seqid", "source", "type", "start", "end", "score", "strand", "phase", "attributes"]
def gff3parser (filename, dictOrf):
""" parser de gff3 """
with open(filename) as f:
for line in f:
if line.startswith("#"):
continue
content = line.strip().split("\t")
if len(content) == len(contentGFF):
value = [content[3], content[4], content[6]]
#print(value)
#print(content[8])
numORF = content[8].strip().split(";")
#print(numORF)
for product in numORF:
if re.search(r"^product=ORF\d{0,3}", product):
keys = product[11:]
dictOrf[keys] = value
return {}
# Usage :
orf = {}
gff3parser(gffname,orf) #avec gffname le nom du fichier gff3 à parser
1/5 - [ rating]