| 87 | } |
| 88 | |
| 89 | bool buildTranscript(int sp, int ep) { |
| 90 | int cur_s, cur_e; // current_start, current_end |
| 91 | vector<Interval> vec; |
| 92 | |
| 93 | string transcript_id = items[sp].getTranscriptID(); |
| 94 | string gene_id = items[sp].getGeneID(); |
| 95 | string gene_name = "", transcript_name = ""; |
| 96 | |
| 97 | char strand = items[sp].getStrand(); |
| 98 | string seqname = items[sp].getSeqName(); |
| 99 | string left = items[sp].getLeft(); |
| 100 | |
| 101 | vec.clear(); |
| 102 | cur_s = cur_e = -1; |
| 103 | for (int i = sp; i <= ep; i++) { |
| 104 | int start = items[i].getStart(); |
| 105 | int end = items[i].getEnd(); |
| 106 | |
| 107 | general_assert(strand == items[i].getStrand(), "According to the GTF file given, transcript " + transcript_id + " has exons from different orientations!"); |
| 108 | general_assert(seqname == items[i].getSeqName(), "According to the GTF file given, transcript " + transcript_id + " has exons on multiple chromosomes!"); |
| 109 | |
| 110 | if (items[i].getGeneName() != "") { |
| 111 | if (gene_name == "") gene_name = items[i].getGeneName(); |
| 112 | else general_assert(gene_name == items[i].getGeneName(), "Transcript " + transcript_id + " is associated with multiple gene names!"); |
| 113 | } |
| 114 | if (items[i].getTranscriptName() != "") { |
| 115 | if (transcript_name == "") transcript_name = items[i].getTranscriptName(); |
| 116 | else general_assert(transcript_name == items[i].getTranscriptName(), "Transcript " + transcript_id + " is associated with multiple transcript names!"); |
| 117 | } |
| 118 | |
| 119 | if (cur_e + 1 < start) { |
| 120 | if (cur_s > 0) vec.push_back(Interval(cur_s, cur_e)); |
| 121 | cur_s = start; |
| 122 | } |
| 123 | cur_e = (cur_e < end ? end : cur_e); |
| 124 | } |
| 125 | if (cur_s > 0) vec.push_back(Interval(cur_s, cur_e)); |
| 126 | |
| 127 | transcripts.add(Transcript(transcript_id, gene_id, seqname, strand, vec, left, transcript_name, gene_name)); |
| 128 | |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | void parse_gtf_file(char* gtfF) { |
| 133 | ifstream fin(gtfF); |
no test coverage detected