| 1 | /* |
| 2 | * \file UTRs.hpp |
| 3 | */ |
| 4 | |
| 5 | #ifndef UTRS_HPP_ |
| 6 | #define UTRS_HPP_cxx . . $ `auxprogs/utrrnaseq/src/UTRs.hpp:6:9`! |
| 7 | |
| 8 | #include "Genomic_Data.hpp"cxx . . $ `<file>/auxprogs/utrrnaseq/src/Genomic_Data.hpp`/ |
| 9 | |
| 10 | #include <vector> |
| 11 | #include <string> |
| 12 | |
| 13 | /** |
| 14 | * @brief Determines the UTRs and writes them into an output file. |
| 15 | */ |
| 16 | class UTRscxx . . $ UTRs# { |
| 17 | |
| 18 | public: |
| 19 | |
| 20 | /** |
| 21 | * @brief All parameters that can be set by the user. |
| 22 | * |
| 23 | * All parameters that can be set by the user. For more information for some of the used parameters see |
| 24 | * external documentation: "Finding likely transcript ends based on RNA-Seq coverage". |
| 25 | */ |
| 26 | struct Parameterscxx . . $ UTRs#Parameters# { |
| 27 | stdcxx . . $ std/::stringcxx . . $ std/string# output_fnamecxx . . $ UTRs#Parameters#output_fname.; ///< Name of the output file. |
| 28 | unsigned read_lengthcxx . . $ UTRs#Parameters#read_length.; ///< Length of the reads of the used RNA-Seq Data. |
| 29 | unsigned window_sizecxx . . $ UTRs#Parameters#window_size.; ///< W Smoothing window size (see external literature). |
| 30 | unsigned limitcxx . . $ UTRs#Parameters#limit.; ///< Greatest possible length of an UTR, excluding introns. |
| 31 | unsigned drop_window_sizecxx . . $ UTRs#Parameters#drop_window_size.; ///< V window size after UTR end (see external documentation). |
| 32 | unsigned min_lengthcxx . . $ UTRs#Parameters#min_length.; ///< Minimal length of UTR. |
| 33 | unsigned min_average_covcxx . . $ UTRs#Parameters#min_average_cov.; ///< Minimal average coverage of UTR. |
| 34 | double p_wincxx . . $ UTRs#Parameters#p_win.; ///< Percentage of drop window coverage in comparison to average UTR exon coverage (see external documentation). |
| 35 | double p_intcxx . . $ UTRs#Parameters#p_int.; ///< Percentage of intron coverage in comparison to average UTR exon coverage. |
| 36 | double p_multcxx . . $ UTRs#Parameters#p_mult.; ///< Percentage of multiplicity in comparison to average UTR exon coverage. |
| 37 | bool zero_covcxx . . $ UTRs#Parameters#zero_cov.; ///< False: UTR end due to steepest decline in coverage; True: UTR end where the coverage drops to 0. |
| 38 | }; |
| 39 | |
| 40 | /** |
| 41 | * @brief Gets reference to parameters that can be set by the user. |
| 42 | * @returns Reference to all parameters that can be set by the user. |
| 43 | */ |
| 44 | static Parameterscxx . . $ UTRs#Parameters#& parameterscxx . . $ UTRs#parameters(ee83787a937c0783).() { return s_parameterscxx . . $ UTRs#s_parameters.; }; |
| 45 | |
| 46 | /** |
| 47 | * @brief Deletes all previous UTRs. Important for test cases. |
| 48 | */ |
| 49 | static void clearcxx . . $ UTRs#clear(49f6e7a06ebc5aa8).(); |
| 50 | |
| 51 | /** |
| 52 | * @brief Determines the UTRs from the RNA-Seq coverage data \b wiggle_data for the current scaffold \b curr_scaffold. |
| 53 | * @param curr_scaffold Sequence plus genomic data of the scaffold the UTRs are determined for. |
| 54 | * @param wiggle_data Coverage information for the current scaffold \b curr_scaffold; Key: Position; Value: Coverage. |
| 55 | */ |
| 56 | static void compute_UTRscxx . . $ UTRs#compute_UTRs(1050746d94a50071).(const Genomic_Datacxx . . $ Genomic_Data#::Scaff_plus_Gen_Datacxx . . $ Genomic_Data#Scaff_plus_Gen_Data#& curr_scaffold, |
| 57 | const stdcxx . . $ std/::mapcxx . . $ std/map#<unsigned,double>& wiggle_data); |
| 58 | |
| 59 | /** |
| 60 | * @brief Returns the number of all computed UTRs. |
| 61 | * @return Number of UTRs. |
| 62 | */ |
| 63 | static unsigned sizecxx . . $ UTRs#size(db52760e79bf9054).(); |
| 64 | |
| 65 | /** |
| 66 | * @brief Writes all the computed UTRs into output file. |
| 67 | */ |
| 68 | static void outputcxx . . $ UTRs#output(49f6e7a06ebc5aa8).(); |
| 69 | |
| 70 | struct UTRcxx . . $ UTRs#UTR# { |
| 71 | stdcxx . . $ std/::stringcxx . . $ std/string# namecxx . . $ UTRs#UTR#name.; ///< Name of the scaffold the UTR belongs to. |
| 72 | unsigned startcxx . . $ UTRs#UTR#start.; ///< Start position of the UTR. |
| 73 | unsigned endcxx . . $ UTRs#UTR#end.; ///< End position of the UTR. |
| 74 | stdcxx . . $ std/::stringcxx . . $ std/string# featurecxx . . $ UTRs#UTR#feature.; ///< Either "3'-UTR" or "5'-UTR". |
| 75 | stdcxx . . $ std/::stringcxx . . $ std/string# strandcxx . . $ UTRs#UTR#strand.; ///< Strand of the UTR. Either '+' (plus) or '-' (minus). |
| 76 | stdcxx . . $ std/::stringcxx . . $ std/string# groupcxx . . $ UTRs#UTR#group.; ///< Group attributes, gene id and transcript id, extracted from GTF file with the coding region information. |
| 77 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Genomic_Datacxx . . $ Genomic_Data#::Introncxx . . $ Genomic_Data#Intron#> all_intronscxx . . $ UTRs#UTR#all_introns.; ///< All introns in the UTR. |
| 78 | }; |
| 79 | |
| 80 | /** |
| 81 | * @brief Gets all the computed UTRs. |
| 82 | * @returns All computed UTRs. |
| 83 | */ |
| 84 | static stdcxx . . $ std/::vectorcxx . . $ std/vector#<UTRcxx . . $ UTRs#UTR#>& get_all_UTRscxx . . $ UTRs#get_all_UTRs(3b64b611cbc768dd).() { return s_all_UTRscxx . . $ UTRs#s_all_UTRs.; }; |
| 85 | |
| 86 | private: |
| 87 | |
| 88 | /** |
| 89 | * @brief Removes less likely introns until no introns overlap, which would be biological unlikely. |
| 90 | * @param introns All introns on the same strand and belonging to the same scaffold. |
| 91 | */ |
| 92 | static void remove_overlapping_intronscxx . . $ UTRs#remove_overlapping_introns(de2a15df4b588919).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<Genomic_Datacxx . . $ Genomic_Data#::Introncxx . . $ Genomic_Data#Intron#>* introns); |
| 93 | |
| 94 | /** |
| 95 | * @brief Computes greatest genome positon for UTR end from the genome position at which the computation of the UTR starts. |
| 96 | * @param pos Position in the scaffold where the determination of the UTR starts. |
| 97 | * @param dir Direction of the computation. Either 1 (starting from stop codon on + strand or start codon on - strand) |
| 98 | * or -1 (starting from start codon on + strand or stop codon on - strand). |
| 99 | * @param scaffold_size Length of the scaffold. Number of base pairs in the scaffold. |
| 100 | * @param read_length Length of the reads of the used RNA-Seq Data. |
| 101 | * @param coding_region_boundaries All gene boundaries on the same strand as the UTR. |
| 102 | * @returns Greatest possible position in genome. Either end of scaffold or position before the first gene after \b pos. |
| 103 | */ |
| 104 | static unsigned get_max_poscxx . . $ UTRs#get_max_pos(c50607705bd6be91).(unsigned pos, int dir, unsigned scaffold_size, unsigned read_length, |
| 105 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<Genomic_Datacxx . . $ Genomic_Data#::CRBcxx . . $ Genomic_Data#CRB#>* coding_region_boundaries); |
| 106 | |
| 107 | /** |
| 108 | * @brief Tests if a repeat overlaps with a UTR. |
| 109 | * @param start Start position of the range of the UTR. |
| 110 | * @param end End position of the range of the UTR. |
| 111 | * @param repeats All repeats of the scaffold the UTR belongs to. |
| 112 | * @returns True: if a repeat exists in the UTR; False: if no repeat is in the UTR range. |
| 113 | */ |
| 114 | static bool repeat_in_UTRcxx . . $ UTRs#repeat_in_UTR(9eac1e3975f0f7f9).(unsigned start, unsigned end, stdcxx . . $ std/::vectorcxx . . $ std/vector#<Genomic_Datacxx . . $ Genomic_Data#::Repeatcxx . . $ Genomic_Data#Repeat#>* repeats); |
| 115 | |
| 116 | /** |
| 117 | * @brief Finds all introns in the range from start to end. |
| 118 | * @param start Start position of the range. |
| 119 | * @param end End position of the range. |
| 120 | * @param dir Direction of the computation. Either 1 (starting from stop codon on + strand or start codon on - strand) |
| 121 | * or -1 (starting from start codon on + strand or stop codon on - strand). |
| 122 | * @param all_introns All introns of the same strand as the current start/stop codon, or the UTR that is going to be computed. |
| 123 | * @returns All introns in the range from start to end. |
| 124 | */ |
| 125 | static stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> find_introns_in_rangecxx . . $ UTRs#find_introns_in_range(db512033e08c49f1).(unsigned start, unsigned end, int dir, stdcxx . . $ std/::vectorcxx . . $ std/vector#<Genomic_Datacxx . . $ Genomic_Data#::Introncxx . . $ Genomic_Data#Intron#>* introns); |
| 126 | |
| 127 | static stdcxx . . $ std/::vectorcxx . . $ std/vector#<UTRcxx . . $ UTRs#UTR#> s_all_UTRscxx . . $ UTRs#s_all_UTRs.; ///< All computed UTRs. |
| 128 | static Parameterscxx . . $ UTRs#Parameters# s_parameterscxx . . $ UTRs#s_parameters.; ///< All parameters that can be set by the user. |
| 129 | }; |
| 130 | |
| 131 | #endif /* UTRs_HPP_ */ |