-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathseqdbfromfasta.cpp
55 lines (51 loc) · 1.09 KB
/
seqdbfromfasta.cpp
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
#include "myutils.h"
#include "seqdb.h"
#include "fastaseqsource.h"
#include "fastqseqsource.h"
#include "objmgr.h"
#include "seqinfo.h"
#include "alpha.h"
bool SeqDB::SetIsAligned()
{
m_Aligned = true;
const unsigned SeqCount = GetSeqCount();
for (unsigned SeqIndex = 0; SeqIndex < SeqCount; ++SeqIndex)
{
if (m_SeqLengths[SeqIndex] != m_SeqLengths[0])
{
m_Aligned = false;
break;
}
}
return m_Aligned;
}
void SeqDB::FromFastx(const string &FileName, bool StripGaps)
{
FILE *f = OpenStdioFile(FileName);
if (GetStdioFileSizeB(f) == 0)
Die("Empty file %s", FileName.c_str());
char c;
ReadStdioFile(f, &c, 1);
CloseStdioFile(f);
FileSeqSource *SS = 0;
if (c == '>')
SS = new FASTASeqSource;
else if (c == '@')
SS = new FASTQSeqSource;
else
Die("Unrecognized file type %s", FileName.c_str());
SS->Open(FileName);
SS->m_StripGaps = StripGaps;
FromSS(*SS);
SS->Close();
SetIsAligned();
}
void SeqDB::FromFasta(const string &FileName, bool StripGaps)
{
FASTASeqSource SS;
SS.Open(FileName);
SS.m_StripGaps = StripGaps;
FromSS(SS);
SS.Close();
SetIsAligned();
}