]> git.donarmstrong.com Git - biopieces.git/blob - code_c/Maasha/src/inc/ucsc.h
minor updates
[biopieces.git] / code_c / Maasha / src / inc / ucsc.h
1 /* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
2
3 #define BED_BUFFER         2048
4 #define BED_CHR_MAX          16
5 #define BED_QID_MAX         256
6 #define BED_ITEMRGB_MAX      16
7 #define BED_BLOCKSIZES_MAX  256
8 #define BED_QBEGS_MAX       256
9
10 /* Structure of a BED entry with the 12 BED elements. */
11 /* http://genome.ucsc.edu/FAQ/FAQformat#format1 */
12 struct _bed_entry
13 {
14     int    cols;       /* Number of BED elements used. */
15     char  *chr;        /* Chromosome name. */
16     uint   chr_beg;    /* Chromosome begin position. */
17     uint   chr_end;    /* Chromosome end position. */
18     char  *q_id;       /* Query ID. */
19     int    score;      /* Score. */
20     char   strand;     /* Strand. */
21     uint   thick_beg;  /* Begin position of thick drawing. */
22     uint   thick_end;  /* End position of thick drawing. */
23     char  *itemrgb;    /* RGB color (255,255,255).*/
24     uint   blockcount; /* Number of blocks (exons). */
25     char  *blocksizes; /* Comma separated string of blocks sizes. */
26     char  *q_begs;     /* Comma separated string of block begins. */
27 };
28
29 typedef struct _bed_entry bed_entry;
30
31 /* Returns a new BED entry with memory allocated for */
32 /* a given number of columns. */
33 bed_entry *bed_entry_new( const int cols );
34
35 /* Free memory for a BED entry. */
36 void       bed_entry_destroy( bed_entry *entry );
37
38 /* Get next BED entry of a given number of columns from a file pointer. */
39 bed_entry *bed_entry_get( FILE *fp, const int cols );
40
41 /* Get a singly linked list with all BED entries (of a given number of coluns */
42 /* from a specified file. */
43 list_sl   *bed_entries_get( char *path, const int cols );
44
45 /* Output a given number of columns from a BED entry to stdout. */
46 void       bed_entry_put( bed_entry *entry, int cols );
47
48 /* Output a given number of columns from all BED entries */
49 /* in a singly linked list. */
50 void       bed_entries_put( list_sl *entries, int cols );
51
52 /* Free memory for all BED entries and list nodes. */
53 void       bed_entries_destroy( list_sl **entries_ppt );
54
55 /* Given a path to a BED file, read the given number of cols */
56 /* according to the begin position. The result is written to stdout. */
57 void       bed_file_sort_beg( char *path, int cols );
58
59 /* Given a path to a BED file, read the given number of cols */
60 /* according to the strand AND begin position. The result is written to stdout. */
61 void       bed_file_sort_strand_beg( char *path, int cols );
62
63 /* Given a path to a BED file, read the given number of cols */
64 /* according to the chromosome AND begin position. The result is written to stdout. */
65 void       bed_file_sort_chr_beg( char *path, int cols );
66
67 /* Given a path to a BED file, read the given number of cols */
68 /* according to the chromosome AND strand AND begin position. The result is written to stdout. */
69 void       bed_file_sort_chr_strand_beg( char *path, int cols );
70
71 /* Compare function for sorting a singly linked list of BED entries */
72 /* according to begin position. */
73 int        cmp_bed_sort_beg( const void *a, const void *b );
74
75 /* Compare function for sorting a singly linked list of BED entries */
76 /* according to strand AND begin position. */
77 int        cmp_bed_sort_strand_beg( const void *a, const void *b );
78
79 /* Compare function for sorting a singly linked list of BED entries */
80 /* according to chromosome name AND begin position. */
81 int        cmp_bed_sort_chr_beg( const void *a, const void *b );
82
83 /* Compare function for sorting a singly linked list of BED entries */
84 /* according to chromosome name AND strand AND begin position. */
85 int        cmp_bed_sort_chr_strand_beg( const void *a, const void *b );
86
87