summarylogtreecommitdiffstats
path: root/source.patch
blob: bf9529e65caef4ae8acf3e0edd642d70d6f180f5 (plain)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
diff --git a/output.dat b/AAoutput.dat
similarity index 100%
rename from output.dat
rename to AAoutput.dat
diff --git a/CommonRoutines.H b/CommonRoutines.H
index c56b53b..6b12f5d 100644
--- a/CommonRoutines.H
+++ b/CommonRoutines.H
@@ -53,9 +53,9 @@ bool getDoubleFromString(double &retVal, string s,
 
 bool getDouble(double &retVal, double defaultValue);
 
-bool getInt(int &retVal, int defaultValue);
+bool getInt(long int &retVal, int defaultValue);
 
-bool getIntFromString(int &retVal, string s, int lowBounds, int hiBounds);
+bool getIntFromString(long int &retVal, string s, int lowBounds, long int hiBounds);
 
 int getIntInput(string prompt, int defaultVal, int lowBounds, int hiBounds);
 
@@ -78,7 +78,7 @@ bool fileExists(string fn);
 void getValidDoubleTokens (double &retVal, ifstream &ifs, double low,
                            double hi, string validLabel, int errorCode);
 
-void getValidIntTokens (int &retVal, ifstream &ifs, int low,
+void getValidIntTokens (long int &retVal, ifstream &ifs, int low,
                         int hi, string validLabel, int errorCode);
 
 void getValidCharTokens (string &retVal, ifstream &ifs,
@@ -103,5 +103,3 @@ int findAAindex(char ch);
 //===========================================================================
 //=======================  END OF CommonRoutines.H   ========================
 //===========================================================================
-
-
diff --git a/CommonRoutines.cpp b/CommonRoutines.cpp
index 306280f..410172e 100644
--- a/CommonRoutines.cpp
+++ b/CommonRoutines.cpp
@@ -35,9 +35,11 @@
 #include <iostream>
 #include <fstream>
 #include <vector>
+#include <cstring>
 #include "CommonRoutines.H"
 using namespace std;
 
+const long int HI_BOUND = 1000000000000000001;
 
 //---------------------------------------------------------------------------
 bool isNum(char ch) {
@@ -85,7 +87,7 @@ bool getDoubleFromString(double &retVal, string s,
    lhTok = strtok((char *)s.c_str(), ".");
    rhTok = strtok(NULL, "\n");
 
-   int lhs, rhs;
+   long int lhs, rhs;
    if(rhTok == NULL) {
       if(getIntFromString(lhs, lhTok, -1, 101)) {
          retVal = (double) lhs;
@@ -96,8 +98,10 @@ bool getDoubleFromString(double &retVal, string s,
       }
    }
 
+   // cout << "rhTok: " << rhTok << endl;
+   // cout << "getIntFromString: " << getIntFromString(rhs, rhTok, -1, HI_BOUND) << endl;
    if(getIntFromString(lhs, lhTok, -1, 101) &&
-      getIntFromString(rhs, rhTok, -1, 10001)) {
+      getIntFromString(rhs, rhTok, -1, HI_BOUND)) {
 
       // rhs should be divided accordingly
       int divisor = 1;
@@ -118,7 +122,7 @@ bool getDoubleFromString(double &retVal, string s,
 //---------------------------------------------------------------------------
 
 //---------------------------------------------------------------------------
-bool getIntFromString(int &retVal, string s, int lowBounds, int hiBounds) {
+bool getIntFromString(long int &retVal, string s, int lowBounds, long int hiBounds) {
 
    //**********************************************************************
    // PRE  : defaultValue has been set
@@ -139,10 +143,16 @@ bool getIntFromString(int &retVal, string s, int lowBounds, int hiBounds) {
       if(!isNum(currCh))
          return(false);
       else {
-         int currMult = (int)pow(10,len-i-1);
-         retVal += currMult * ((int)currCh - 48);
+         long int currMult = (long int)pow(10,len-i-1);
+         retVal += currMult * ((long int)currCh - 48);
       }
    }
+
+   // Debugging purpose
+   // cout << "retVal: " << retVal << endl;
+   // cout << "lowBounds: " << lowBounds << endl;
+   // cout << "hiBounds: " << hiBounds << endl;
+   // cout << "(retVal > lowBounds)  && (retVal < hiBounds): " << ((retVal > lowBounds)  && (retVal < hiBounds)) << endl;
    if((retVal > lowBounds)  && (retVal < hiBounds))
       return(true);
    else
@@ -196,7 +206,7 @@ bool getDouble(double &retVal, double defaultValue) {
 //---------------------------------------------------------------------------
 
 //---------------------------------------------------------------------------
-bool getInt(int &retVal, int defaultValue) {
+bool getInt(long int &retVal, int defaultValue) {
 
    //**********************************************************************
    // PRE  : defaultValue has been set
@@ -377,7 +387,7 @@ void getValidDoubleTokens (double &retVal, ifstream &ifs, double low,
 //---------------------------------------------------------------------------
 
 //---------------------------------------------------------------------------
-void getValidIntTokens (int &retVal, ifstream &ifs, int low,
+void getValidIntTokens (long int &retVal, ifstream &ifs, int low,
                         int hi, string validLabel, int errorCode) {
 
    //**********************************************************************
@@ -449,7 +459,7 @@ int getIntInput(string prompt, int defaultVal, int lowBounds, int hiBounds) {
    //**********************************************************************
 
    bool finished = false;
-   int retVal;
+   long int retVal;
 
    while(!finished) {
       cout << prompt;
@@ -688,5 +698,3 @@ int findAAindex(char ch) {
 //===========================================================================
 //=====================  END OF CommonRoutines.cpp ==========================
 //===========================================================================
-
-
diff --git a/Makefile b/Makefile
index c49a584..cf08cc7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 COMPILER = g++
-CCFLAGS = -g
+CCFLAGS = -g -fpermissive
 
 rMotifGen: RandomMotifs.cpp SequenceClass.o CommonRoutines.o SubstitutionMatrices.o PSSM.o
 	${COMPILER} ${CCFLAGS} -o rMotifGen RandomMotifs.cpp SequenceClass.o CommonRoutines.o SubstitutionMatrices.o PSSM.o
diff --git a/PSSM.cpp b/PSSM.cpp
index 7ec0e8e..f29f966 100644
--- a/PSSM.cpp
+++ b/PSSM.cpp
@@ -112,6 +112,7 @@ void PSSM::checkForValidPSSM() {
    else {
       if(!checkColOrientation()) {
          if(!checkRowOrientation()) {
+            cerr << "Invalid orientation" << endl;
             errorVal = 29; // INCORRECTLY FORMATTED PSSM FILE
             return;
          }
@@ -205,6 +206,7 @@ bool PSSM::checkColOrientation() {
          double tmpD;
          ss >> tmpS;
          if(!getDoubleFromString(tmpD, tmpS, 0.0, 10000.0)) {
+            cerr << "Invalid string reading in col orientation"  << endl;
             errorVal = 29;
             return(false);
          }
@@ -286,6 +288,7 @@ bool PSSM::checkRowOrientation() {
          // MAKE SURE EACH COLUMN IS A POSITIVE DOUBLE VALUE
 
          if(!getDoubleFromString(tmpD, tmpS, 0.0, 10000.0)) {
+            cerr << "Invalid string reading in row orientation" << endl;
             errorVal = 29;
             return(false);
          }
diff --git a/README b/README
index 18502c2..ba0164f 100644
--- a/README
+++ b/README
@@ -107,6 +107,7 @@ RUNNING rMotifGen
         motif<X>Type=      // Where X=1..numMotifs --  the value can
                            // be 'U' for user defined, 'R' for random
                            // or 'P' for PSSM
+        motif<X>PSSMFILE=  // PSSM filename if motif<X>Type=P
         motif<X>Seq=       // Only Valid if Type = 'U' -- consensus motif
         motif<X>PctSeqsContain= // Percentage of sequences that contain this 
                                 // motif 
diff --git a/RandomMotifs.cpp b/RandomMotifs.cpp
index 9d66902..5e59a90 100644
--- a/RandomMotifs.cpp
+++ b/RandomMotifs.cpp
@@ -505,7 +505,7 @@ void getRandomMotifInfo(ifstream &infile, char *&motif_createTypeArr,
     string motifLabel = setMotifLabel(i);
     string currLabel = motifLabel + "Len";
 
-    int tmpint;
+    long int tmpint;
     if(infile.eof()) { exit(26); }
     getValidIntTokens(tmpint, infile, 0, 101, currLabel, 18);
     motif_lenArr[i] = tmpint;
@@ -580,7 +580,7 @@ void getPAMValue(PAM **&motif_PAMArr, ifstream &infile,
    //**********************************************************************
 
     string currLabel = motifLabel + "PAM";
-    int pamVal;
+    long int pamVal;
     if(infile.eof()) { exit(26); }
     getValidIntTokens(pamVal, infile, -1, 501, currLabel, 17);
     motif_PAMArr[i] = new PAM(pamVal);
@@ -601,9 +601,9 @@ void fileMode(string FN, char seqType){
 
    double *ResiduePcts;
    char   *ResidueLabels;
-   int seqLen;
-   int numMotifs;
-   int numSeqs;
+   long int seqLen;
+   long int numMotifs;
+   long int numSeqs;
    bool finished;
    char   *motif_createTypeArr;
    bool   *motif_isPalindromicArr;
@@ -675,7 +675,7 @@ void fileMode(string FN, char seqType){
          }
          motif_PSSMArr[i] = currPSSM;
          currLabel = motifLabel + "PctSeqsContain";
-         int tmpint;
+         long int tmpint;
          if(infile.eof()) { exit(26); }
          getValidIntTokens(tmpint, infile, -1, 101, currLabel, 16);
           motif_pctSeqConsArr[i] = tmpint;
@@ -872,7 +872,3 @@ int main(int argc, char *argv[]) {
 //============================================================================
 //--------------------------- END OF RandomMotifs.cpp ------------------------
 //============================================================================
-
-
-
-
diff --git a/SequenceClass.cpp b/SequenceClass.cpp
index 45c121f..92035c1 100644
--- a/SequenceClass.cpp
+++ b/SequenceClass.cpp
@@ -144,7 +144,7 @@ string SequenceClass::randomPSSMSeq(PSSM *P) {
          }
       }
       if(!nextFound) {
-         s+= P->residueArr[P->totRows - 1];
+         s+= P->residueArr[P->totCols - 1];
       }
    }
    return(s);