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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
/*
Ray
Copyright (C) 2011, 2012 Sébastien Boisvert
http://DeNovoAssembler.SourceForge.Net/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You have received a copy of the GNU General Public License
along with this program (gpl-3.0.txt).
see <http://www.gnu.org/licenses/>
*/
#include "ScaffoldingEdge.h"
#include <iostream>
#include <sstream>
#include <string>
#include <assert.h>
using namespace std;
ScaffoldingEdge::ScaffoldingEdge(PathHandle leftContig,Strand leftStrand,PathHandle rightContig,Strand rightStrand,int gapSize,
int average1,int count1,int standardDeviation1,
int average2,int count2,int standardDeviation2){
m_gapSize=gapSize;
m_leftContig=leftContig;
m_leftStrand=leftStrand;
m_rightContig=rightContig;
m_rightStrand=rightStrand;
m_count1=count1;
m_average1=average1;
m_standardDeviation1=standardDeviation1;
m_count2=count2;
m_average2=average2;
m_standardDeviation2=standardDeviation2;
}
ScaffoldingEdge ScaffoldingEdge::getReverseEdge(){
char reverseLeft='F';
if(m_leftStrand=='F')
reverseLeft='R';
char reverseRight='F';
if(m_rightStrand=='F')
reverseRight='R';
ScaffoldingEdge e2(m_rightContig,reverseRight,m_leftContig,reverseLeft,m_gapSize,m_average2,m_count2,m_standardDeviation2,m_average1,m_count1,m_standardDeviation1);
return e2;
}
PathHandle ScaffoldingEdge::getLeftContig(){
return m_leftContig;
}
Strand ScaffoldingEdge::getLeftStrand(){
return m_leftStrand;
}
PathHandle ScaffoldingEdge::getRightContig(){
return m_rightContig;
}
Strand ScaffoldingEdge::getRightStrand(){
return m_rightStrand;
}
int ScaffoldingEdge::getAverage1(){
return m_average1;
}
int ScaffoldingEdge::getCount1(){
return m_count1;
}
int ScaffoldingEdge::getStandardDeviation1(){
return m_standardDeviation1;
}
int ScaffoldingEdge::getAverage2(){
return m_average2;
}
int ScaffoldingEdge::getCount2(){
return m_count2;
}
int ScaffoldingEdge::getStandardDeviation2(){
return m_standardDeviation2;
}
void ScaffoldingEdge::read(ifstream*f){
/*
version 1
contig-0 F contig-2000306 F 7414 2 0 7384 40 1 7444 37
version 2
contig-0 R contig-356000158 F 9012 2 0 3 9012 0 1 3 9012 0
*/
{
string token;
(*f)>>token;
string number=token.substr(7,token.length()-7);
stringstream aStream;
aStream << number;
aStream >> m_leftContig;
}
(*f) >> m_leftStrand;
{
string token;
(*f)>>token;
string number=token.substr(7,token.length()-7);
stringstream aStream;
aStream << number;
aStream >> m_rightContig;
}
(*f) >> m_rightStrand;
(*f) >> m_gapSize;
int dummy;
(*f) >> dummy; /* count */
(*f) >> dummy; /* index */
(*f) >> m_count1;
(*f) >> m_average1;
(*f) >> m_standardDeviation1;
(*f) >> dummy; /* index */
(*f) >> m_count2;
(*f) >> m_average2;
(*f) >> m_standardDeviation2;
}
ScaffoldingEdge::ScaffoldingEdge(){
}
int ScaffoldingEdge::getPriority()const {
return (m_count1+m_count2)/2;
}
bool ScaffoldingEdge::operator<(const ScaffoldingEdge&other)const{
return getPriority()<other.getPriority();
}
void ScaffoldingEdge::print(){
cout<<m_leftContig<<" "<<m_leftStrand<<" "<<m_rightContig<<" "<<m_rightStrand<<" gap= "<<m_gapSize<<" priority= "<<getPriority()<<endl;
}
Strand ScaffoldingEdge::getStrand(PathHandle name){
#ifdef CONFIG_ASSERT
assert(name==getLeftContig() || name==getRightContig());
#endif
if(name==getLeftContig())
return getLeftStrand();
else if(name==getRightContig())
return getRightStrand();
return 'x';
}
int ScaffoldingEdge::getSide(PathHandle name){
#ifdef CONFIG_ASSERT
assert(name==getLeftContig() || name==getRightContig());
#endif
if(name==getLeftContig())
return LEFT_SIDE;
else if(name==getRightContig())
return RIGHT_SIDE;
return -1;
}
int ScaffoldingEdge::getGapSize(){
return m_gapSize;
}
|