~ubuntu-branches/ubuntu/saucy/abyss/saucy

« back to all changes in this revision

Viewing changes to Common/Estimate.h

  • Committer: Package Import Robot
  • Author(s): Shaun Jackman
  • Date: 2011-09-11 10:00:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: package-import@ubuntu.com-20110911100013-oa4m5fi036mjuwc8
Tags: 1.3.0-1
* New upstream release.
* Add libboost-graph-dev to Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
#include "ContigID.h"
5
5
#include "ContigNode.h"
 
6
#include "Graph/Options.h" // for opt::k
6
7
#include "IOUtil.h"
7
8
#include <cassert>
8
9
#include <cmath> // for ceilf
14
15
#include <string>
15
16
 
16
17
namespace opt {
17
 
        extern int dot;
18
 
 
19
18
        /** The acceptable error of a distance estimate. */
20
19
        extern unsigned distanceError;
21
20
}
27
26
        unsigned numPairs;
28
27
        float stdDev;
29
28
 
 
29
        DistanceEst() : distance(-opt::k + 1), numPairs(0), stdDev(0) { }
 
30
 
 
31
        DistanceEst(int distance)
 
32
                : distance(distance), numPairs(0), stdDev(distance) { }
 
33
 
 
34
        DistanceEst(int distance, unsigned numPairs, float stdDev)
 
35
                : distance(distance), numPairs(numPairs), stdDev(stdDev) { }
 
36
 
30
37
        bool operator==(const DistanceEst& o) const
31
38
        {
32
39
                return distance == o.distance
37
44
        friend std::ostream& operator<<(std::ostream& out,
38
45
                        const DistanceEst& o)
39
46
        {
40
 
                if (opt::dot)
41
 
                        return out <<
42
 
                                "d=" << o.distance << " "
43
 
                                "e=" << std::fixed << std::setprecision(1)
44
 
                                        << o.stdDev << " "
45
 
                                "n=" << o.numPairs;
46
 
                else
 
47
                if (opt::format == DOT) {
 
48
                        out << "d=" << o.distance;
 
49
                        if (o.stdDev > 0 || o.numPairs > 0)
 
50
                                out << " e=" << std::fixed << std::setprecision(1)
 
51
                                        << o.stdDev
 
52
                                        << " n=" << o.numPairs;
 
53
                        return out;
 
54
                } else
47
55
                        return out << o.distance << ',' << o.numPairs << ','
48
56
                                << std::fixed << std::setprecision(1) << o.stdDev;
49
57
        }
50
58
 
51
59
        friend std::istream& operator>>(std::istream& in, DistanceEst& o)
52
60
        {
53
 
                if (in >> std::ws && in.peek() == 'd')
54
 
                        return in >> expect("d =") >> o.distance
55
 
                                >> expect(" e =") >> o.stdDev
56
 
                                >> expect(" n =") >> o.numPairs;
57
 
                else
 
61
                if (in >> std::ws && in.peek() == 'd') {
 
62
                        if (!(in >> expect("d =") >> o.distance >> std::ws))
 
63
                                return in;
 
64
                        if (in.peek() == ']') {
 
65
                                o.stdDev = o.numPairs = 0;
 
66
                                return in;
 
67
                        } else
 
68
                                return in >> expect(" e =") >> o.stdDev
 
69
                                        >> expect(" n =") >> o.numPairs;
 
70
                } else
58
71
                        return in >> o.distance >> expect(",")
59
72
                                >> o.numPairs >> expect(",")
60
73
                                >> o.stdDev;
72
85
        friend std::ostream& operator<<(std::ostream& out,
73
86
                        const Estimate& o)
74
87
        {
75
 
                if (opt::dot)
 
88
                if (opt::format == DOT)
76
89
                        return out << '"' << o.contig << "\" ["
77
90
                                "d=" << o.distance << " "
78
91
                                "e=" << std::fixed << std::setprecision(1)