-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIsochoreFile.C
45 lines (38 loc) · 1.29 KB
/
IsochoreFile.C
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
/****************************************************************
IsochoreFile.C
Copyright (C)2013 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.
****************************************************************/
#include "IsochoreFile.H"
#include <iostream>
#include "BOOM/File.H"
// G+C <= 100% : genezilla.cfg
BOOM::Regex IsochoreFile::lineRegex(
"G[+]C\\s*<=\\s*(\\S+)%\\s*:\\s*(\\S+)");
BOOM::ConfigFile *IsochoreFile::parse(const BOOM::String &filename,
double gcContent,
BOOM::String &gffMessage)
{
gcContent*=100;
BOOM::File infile(filename);
while(!infile.eof())
{
BOOM::String line=infile.readLine();
if(lineRegex.search(line))
{
double upperBound=lineRegex[1].asDouble();
BOOM::String configFilename=lineRegex[2];
if(gcContent<=upperBound)
{
cerr << "\tG+C%=" << gcContent << " <= " << upperBound
<< " -> using " << configFilename << endl;
gffMessage=BOOM::String("# G+C=")+int(10*gcContent)/10.0+
"% -- used isochore file: "+configFilename;
return new BOOM::ConfigFile(configFilename);
}
}
}
throw BOOM::String("Error parsing ")+filename+" : G+C content = "+
gcContent+"%";
}