gff.c
/***************************************************************************
 *  Library:
 *      #include <biolibc/gff.h>
 *      -lbiolibc -lxtend
 *
 *  Description:
 *      Copy GFF fields to a BED structure to the extent possible.  Since
 *      GFF and BED files do not necessarily contain the same information,
 *      some information may be lost or filled in with appropriate markers.
 *
 *  Arguments:
 *      gff_feature  Pointer to the bl_gff_t structure to copy
 *      bed_feature  Pointer to the bl_bed_t structure to receive data
 *
 *  See also:
 *      bl_bed_read(3), bl_gff_read(3)
 *
 *  History: 
 *  Date        Name        Modification
 *  2021-04-19  Jason Bacon Begin
 ***************************************************************************/
#include 
-lbiolibc -lxtend

Copy GFF fields to a BED structure to the extent possible.  Since
GFF and BED files do not necessarily contain the same information,
some information may be lost or filled in with appropriate markers.





Date        Name        Modification
2021-04-19  Jason Bacon Begin
#include - lbiolibc - lxtend Copy GFF fields to a BED structure to the extent possible . Since GFF and BED files do not necessarily contain the same information some information may be lost or filled in with appropriate markers . Date Name Modification 2021 - 04 - 19 Jason Bacon Begin
void    bl_gff_to_bed(bl_gff_t *gff_feature, bl_bed_t *bed_feature)
{
    char    name[BL_BED_NAME_MAX_CHARS + 1],
	    strand = BL_GFF_STRAND(gff_feature);
    bl_bed_set_fields(bed_feature, 6);
    bl_bed_set_score(bed_feature, 0);
    bl_bed_set_chrom_cpy(bed_feature, BL_GFF_SEQID(gff_feature), BL_CHROM_MAX_CHARS + 1);
    bl_bed_set_chrom_start(bed_feature, BL_GFF_START(gff_feature) - 1);
    bl_bed_set_chrom_end(bed_feature, BL_GFF_END(gff_feature));
    snprintf(name, BL_BED_NAME_MAX_CHARS + 1, "%s", BL_GFF_TYPE(gff_feature));
    bl_bed_set_name_cpy(bed_feature, name, BL_BED_NAME_MAX_CHARS + 1);
    bl_bed_set_score(bed_feature, 0);  
    if ( bl_bed_set_strand(bed_feature, strand) != BL_BED_DATA_OK )
    {
	fputs("bl_gff_to_bed(): bl_bed_set_strand() failed.\n", stderr);
	exit(EX_DATAERR);
    }
}
void bl_gff_to_bed ( bl_gff_t * gff_feature , bl_bed_t * bed_feature ) { char name [ BL_BED_NAME_MAX_CHARS + 1 ] , strand = BL_GFF_STRAND ( gff_feature ) ; bl_bed_set_fields ( bed_feature , 6 ) ; bl_bed_set_score ( bed_feature , 0 ) ; bl_bed_set_chrom_cpy ( bed_feature , BL_GFF_SEQID ( gff_feature ) , BL_CHROM_MAX_CHARS + 1 ) ; bl_bed_set_chrom_start ( bed_feature , BL_GFF_START ( gff_feature ) - 1 ) ; bl_bed_set_chrom_end ( bed_feature , BL_GFF_END ( gff_feature ) ) ; snprintf ( name , BL_BED_NAME_MAX_CHARS + 1 , " " , BL_GFF_TYPE ( gff_feature ) ) ; bl_bed_set_name_cpy ( bed_feature , name , BL_BED_NAME_MAX_CHARS + 1 ) ; bl_bed_set_score ( bed_feature , 0 ) ; if ( bl_bed_set_strand ( bed_feature , strand ) != BL_BED_DATA_OK ) { fputs ( " \n " , stderr ) ; exit ( EX_DATAERR ) ; } }
Library:
      #include <biolibc/gff.h>
      -lbiolibc -lxtend
Library : #include <biolibc / gff . h > - lbiolibc - lxtend
// Update this if/when more fields are converted /*
     *  BED start is 0-based and inclusive
     *  GFF is 1-based and inclusive
     */ /*
     *  BED end is 0-base and inclusive (or 1-based and non-inclusive)
     *  GFF is the same
     */ // FIXME: Take as arg?