Entering edit mode
3.1 years ago
Irsan
★
7.8k
How do you most efficiently write a collection of gffutils.feature.Feature objects to file, so that you can create a gff3 file from a collection of Feature objects? I am trying to create a gff3 file without the ##FASTA part at the bottom, so I think I dont need the actual sequence records. Options I so far have are
- Writing my own code, converting a Feature object to string. Have to take care with converting the attributes and all its items to an appropriate string representation
- Converting gffutils.feature.Feature to Bio.SeqIO.SeqRecord objects, and using GFF.write() to create my file
- I found some (old?) documentation that you could convert at Feature object to string by str(my_feature) or my_feature.str() or my_feature.to_string() but all those didnt work
my_feature = gffutils.feature.feature_from_line('contig_A\texample\texon\t1\t100\t.\t+\t.\tName=seq_A') str(my_feature) my_feature.str() my_feature.to_string()
Excellent, my issue was that I am using Feature objects instantiated by myself using the Feature constructor. When I used floats for certain values in the Feature attributes and then the str() function crashes on converting those floats. When I instantiate a Feature object where all values in the attributes are strings it goes well!