<div dir="ltr">Hi all,<div>I have the below GFF3 file:</div><div><br></div><div><i>##gff-version 3<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â gene Â  Â 98177 Â  99675 Â  . Â  Â  Â  - Â  Â  Â  . Â  Â  Â  ID=Nb3PK39646.path1;Name=Peroxidase 40<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â mRNA Â  Â 98177 Â  99675 Â  . Â  Â  Â  - Â  Â  Â  . Â  Â  Â  ID=Nb3PK39646.mrna1;Parent=Nb3PK39646.path1;Name=Nb3PK39646;coverage=99.8;identity=99.9;matches=1011;mismatches=1;indels=0;unknowns=0<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â exon Â  Â 98177 Â  98571 Â  100 Â  Â  - Â  Â  Â  . Â  Â  Â  ID=Nb3PK39646.mrna1.exon4;Parent=Nb3PK39646.mrna1;Name=Nb3PK39646;Target=Nb3PK39646 620 1014 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â CDS Â  Â  98177 Â  98571 Â  100 Â  Â  - Â  Â  Â  2 Â  Â  Â  ID=Nb3PK39646.mrna1.cds4;Parent=Nb3PK39646.mrna1;Name=Nb3PK39646;Target=Nb3PK39646 620 1014 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â exon Â  Â 98679 Â  98844 Â  100 Â  Â  - Â  Â  Â  . Â  Â  Â  ID=Nb3PK39646.mrna1.exon3;Parent=Nb3PK39646.mrna1;Name=Nb3PK39646;Target=Nb3PK39646 454 619 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â CDS Â  Â  98679 Â  98844 Â  100 Â  Â  - Â  Â  Â  0 Â  Â  Â  ID=Nb3PK39646.mrna1.cds3;Parent=Nb3PK39646.mrna1;Name=Nb3PK39646;Target=Nb3PK39646 454 619 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â exon Â  Â 99134 Â  99325 Â  99 Â  Â  Â - Â  Â  Â  . Â  Â  Â  ID=Nb3PK39646.mrna1.exon2;Parent=Nb3PK39646.mrna1;Name=Nb3PK39646;Target=Nb3PK39646 262 453 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â CDS Â  Â  99134 Â  99325 Â  99 Â  Â  Â - Â  Â  Â  0 Â  Â  Â  ID=Nb3PK39646.mrna1.cds2;Parent=Nb3PK39646.mrna1;Name=Nb3PK39646;Target=Nb3PK39646 262 453 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â CDS Â  Â  99417 Â  99674 Â  100 Â  Â  - Â  Â  Â  0 Â  Â  Â  ID=Nb3PK39646.mrna1.cds1;Parent=Nb3PK39646.mrna1;Name=Nb3PK39646;Target=Nb3PK39646 4 261 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â exon Â  Â 99417 Â  99675 Â  100 Â  Â  - Â  Â  Â  . Â  Â  Â  ID=Nb3PK39646.mrna1.exon1;Parent=Nb3PK39646.mrna1;Name=Nb3PK39646;Target=Nb3PK39646 3 261 +<br>###<br></i>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â gene Â  Â 1115558 1121491 . Â  Â  Â  + Â  Â  Â  . Â  Â  Â  ID=Nb3PK08375.path1;Name=Putative uncharacterized protein At1g50120<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â mRNA Â  Â 1115558 1121491 . Â  Â  Â  + Â  Â  Â  . Â  Â  Â  ID=Nb3PK08375.mrna1;Parent=Nb3PK08375.path1;Name=Nb3PK08375;coverage=100.0;identity=100.0;matches=399;mismatches=0;indels=0;unknowns=0<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â exon Â  Â 1115558 1115879 100 Â  Â  + Â  Â  Â  . Â  Â  Â  ID=Nb3PK08375.mrna1.exon1;Parent=Nb3PK08375.mrna1;Name=Nb3PK08375;Target=Nb3PK08375 1 322 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â CDS Â  Â  1115558 1115879 100 Â  Â  + Â  Â  Â  0 Â  Â  Â  ID=Nb3PK08375.mrna1.cds1;Parent=Nb3PK08375.mrna1;Name=Nb3PK08375;Target=Nb3PK08375 1 322 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â exon Â  Â 1121415 1121491 100 Â  Â  + Â  Â  Â  . Â  Â  Â  ID=Nb3PK08375.mrna1.exon2;Parent=Nb3PK08375.mrna1;Name=Nb3PK08375;Target=Nb3PK08375 323 399 +<br>NbV1Ch01 Â  Â  Â  Â NbGenome Â  Â  Â  Â CDS Â  Â  1121415 1121491 100 Â  Â  + Â  Â  Â  2 Â  Â  Â  ID=Nb3PK08375.mrna1.cds2;Parent=Nb3PK08375.mrna1;Name=Nb3PK08375;Target=Nb3PK08375 323 399 +<br>###<i><br></i></div><div><i>...</i><br><br>I would like to copy the "<i>Name=Peroxidase 40"</i> from gene feature and added into mRNA feature as "<i>Note=Peroxidase 40</i>". Unfortunately, the below script caused an error:<br></div><div><br></div><div><i>import pprint<br>from BCBio import GFF<br><br>in_file = "/Users/lorencm/tmp/Gmp_NbV1_Final.gff3"<br>out_file = "/Users/lorencm/tmp/Gmp_NbV1_Final.gff3.bak"<br>in_handle = open(in_file)<br><br>with open(out_file, "w") as out_handle:<br>  Â  for rec in GFF.parse(in_handle):<br>  Â  Â  Â  for feature in rec.features:<br>  Â  Â  Â  Â  Â  print(feature)<br>  Â  Â  Â  Â  Â  print(feature.qualifiers.get("Name"))<br>  Â  Â  Â  Â  Â  print(feature.sub_features)<br>  Â  Â  Â  Â  Â  print(feature.sub_features[0].qualifiers.get("Name"))<br>  Â  Â  Â  Â  Â  print("!!!!change")<br>  Â  Â  Â  Â  Â  feature.sub_features[0].qualifiers["Note"] = feature.qualifiers.get("Name")<br>  Â  Â  Â  Â  Â  pprint.pprint(feature.sub_features[0].qualifiers.get("Note"))<br>  Â  Â  Â  Â  Â  print("!!!DONE")<br>  Â  Â  Â  Â  Â  out_file.write([rec])<br>in_handle.close()</i><br></div><div> </div><div>Here is output and error:</div><div><br></div><div><i>python /projects/test.py<br>type: gene<br>location: [98176:99675](-)<br>id: Nb3PK39646.path1<br>qualifiers:<br>  Â  Key: ID, Value: ['Nb3PK39646.path1']<br>  Â  Key: Name, Value: ['Peroxidase 40']<br>  Â  Key: source, Value: ['NbGenome']<br><br>['Peroxidase 40']<br>[SeqFeature(FeatureLocation(ExactPosition(98176), ExactPosition(99675), strand=-1), type='mRNA', id='Nb3PK39646.mrna1')]<br>['Nb3PK39646']<br>!!!!change<br>['Peroxidase 40']<br>!!!DONE<br>Traceback (most recent call last):<br>  File "test.py", line 19, in <module><br>  Â  out_file.write([rec])<br>AttributeError: 'str' object has no attribute 'write'</i><br><div><br></div></div><div>What did I miss?</div><div><br></div><div>Thank you in advance,</div><div><br></div><div>Mic</div></div>