-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodonIterator.H
57 lines (49 loc) · 1.88 KB
/
CodonIterator.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/****************************************************************
CodonIterator.H
Copyright (C)2015 William H. Majoros ([email protected]).
This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
License (GPL) version 3, as described at www.opensource.org.
****************************************************************/
#ifndef INCL_CodonIterator_H
#define INCL_CodonIterator_H
#include <iostream>
#include "String.H"
#include "GffTranscript.H"
using namespace std;
using namespace BOOM;
/****************************************************************
struct Codon
****************************************************************/
struct Codon {
String codon;
int globalCoord; // coordinate on substrate
int splicedCoord; // coordinate in spliced transcript (including 5'UTR)
int cdsCoord; // coordinate within spliced CDS (not including UTR)
GffExon *exon; // which exon it starts in (it might span an intron)
bool valid() const;
bool isStop() const; // human-specific: TAG/TGA/TAA
Codon() : exon(NULL) {}
};
/****************************************************************
class CodonIterator
****************************************************************/
class CodonIterator {
public:
// NOTE: this class currently only works for the forward strand!
CodonIterator(const GffTranscript &,const String &substrate);
CodonIterator(const GffTranscript &,const Vector<GffExon*> &rawExons,
const String &substrate);
bool nextCodon(Codon &); // return false if no more
protected:
const GffTranscript &transcript;
const String &substrate;
GffExon *currentExon;
const Vector<GffExon*> &exons;
int atgExon, atgPosInExon, utr5len;
int currentExonIndex;
int posWithinExon;
int splicedPos; // includes 5'UTR
int cdsPos; // position within CDS (spliced), not including UTR
void reset();
};
#endif