Last active
December 22, 2015 20:58
-
-
Save standage/6529770 to your computer and use it in GitHub Desktop.
My attempt to reproduce the behavior I described in https://github.com/genometools/genometools/issues/115.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##gff-version 3 | |
| ##sequence-region PdomScaf0001 252075 255869 | |
| PdomScaf0001 maker mRNA 252075 255869 . - . ID=PdomMRNAr1.1-00022.1;_AED=0.29;_eAED=0.29;_QI=0|0.5|0.33|1|1|1|3|893|923 | |
| PdomScaf0001 maker exon 252075 255370 118 - . Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 maker stop_codon 252968 252970 . - . Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 . CDS 252968 255370 . - . ID=myCDS;Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 maker exon 255453 255790 35.2 - . Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 . CDS 255453 255790 . - . ID=myCDS;Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 maker exon 255839 255869 9.8 - . Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 . CDS 255839 255869 . - . ID=myCDS;Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 maker start_codon 255867 255869 . - . Parent=PdomMRNAr1.1-00022.1 | |
| ### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##gff-version 3 | |
| ##sequence-region PdomScaf0001 252075 255869 | |
| PdomScaf0001 maker mRNA 252075 255869 . - . ID=PdomMRNAr1.1-00022.1;_AED=0.29;_eAED=0.29;_QI=0|0.5|0.33|1|1|1|3|893|923 | |
| PdomScaf0001 maker exon 252075 255370 118 - . Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 maker stop_codon 252968 252970 . - . Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 maker exon 255453 255790 35.2 - . Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 maker exon 255839 255869 9.8 - . Parent=PdomMRNAr1.1-00022.1 | |
| PdomScaf0001 maker start_codon 255867 255869 . - . Parent=PdomMRNAr1.1-00022.1 | |
| ### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define WITHOUT_CAIRO | |
| #include "genometools.h" | |
| int main(int argc, const char **argv) | |
| { | |
| GtArray *nodes; | |
| GtError *error; | |
| GtFile *outfile; | |
| GtNodeStream *gff3in, *arrayoutstream, *arrayinstream, *gff3out; | |
| gt_lib_init(); | |
| gff3in = gt_gff3_in_stream_new_unsorted(1, &argv[1]); | |
| gt_gff3_in_stream_check_id_attributes((GtGFF3InStream *)gff3in); | |
| gt_gff3_in_stream_enable_tidy_mode((GtGFF3InStream *)gff3in); | |
| error = gt_error_new(); | |
| nodes = gt_array_new( sizeof(GtGenomeNode *) ); | |
| arrayoutstream = gt_array_out_stream_new(gff3in, nodes, error); | |
| int result = gt_node_stream_pull(arrayoutstream, error); | |
| if(result == -1) | |
| { | |
| fprintf(stderr, "error processing node stream: %s", gt_error_get(error)); | |
| } | |
| gt_node_stream_delete(gff3in); | |
| gt_node_stream_delete(arrayoutstream); | |
| GtUword i; | |
| for(i = 0; i < gt_array_size(nodes); i++) | |
| { | |
| GtGenomeNode **gn = gt_array_get(nodes, i); | |
| GtFeatureNode *fn = gt_feature_node_try_cast(*gn); | |
| if(fn == NULL) | |
| continue; | |
| GtStr *seqid = gt_genome_node_get_seqid(*gn); | |
| GtGenomeNode *cdspart3 = gt_feature_node_new(seqid, "CDS", 252968, 255370, GT_STRAND_REVERSE); | |
| GtGenomeNode *cdspart2 = gt_feature_node_new(seqid, "CDS", 255453, 255790, GT_STRAND_REVERSE); | |
| GtGenomeNode *cdspart1 = gt_feature_node_new(seqid, "CDS", 255839, 255869, GT_STRAND_REVERSE); | |
| gt_feature_node_make_multi_representative((GtFeatureNode *)cdspart3); | |
| gt_feature_node_set_multi_representative((GtFeatureNode *)cdspart2, (GtFeatureNode *)cdspart3); | |
| gt_feature_node_set_multi_representative((GtFeatureNode *)cdspart1, (GtFeatureNode *)cdspart3); | |
| gt_feature_node_add_child(fn, (GtFeatureNode *)cdspart1); | |
| gt_feature_node_add_child(fn, (GtFeatureNode *)cdspart2); | |
| gt_feature_node_add_child(fn, (GtFeatureNode *)cdspart3); | |
| gt_feature_node_set_attribute((GtFeatureNode *)cdspart3, "ID", "myCDS"); | |
| } | |
| GtUword progress = 0; | |
| arrayinstream = gt_array_in_stream_new(nodes, &progress, error); | |
| outfile = gt_file_new_from_fileptr(stdout); | |
| gff3out = gt_gff3_out_stream_new(arrayinstream, outfile); | |
| gt_gff3_out_stream_retain_id_attributes((GtGFF3OutStream *)gff3out); | |
| result = gt_node_stream_pull(gff3out, error); | |
| if(result == -1) | |
| { | |
| fprintf(stderr, "error processing node stream: %s", gt_error_get(error)); | |
| } | |
| gt_file_delete_without_handle(outfile); | |
| gt_node_stream_delete(arrayinstream); | |
| gt_node_stream_delete(gff3out); | |
| gt_array_delete(nodes); | |
| gt_error_delete(error); | |
| gt_lib_clean(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment