GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Dec-2004, 22:55
vivina vivina is offline
New Member
 
Join Date: Dec 2004
Posts: 7
vivina is on a distinguished road

need help with some c++ coding..


i'm suppose to write out a program to convert a text file to a format whereby "Fly" program can read and draw the picture..
But it cant seem to be able to read properly from my text file or what coz when it draws the picture out it get abit distorted..

Here's my program:
CPP / C++ / C Code:
#include <string>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <strstream>
#include "FileConverter.h"
using namespace std;


FileConverter::FileConverter(char *in){
	inputFilePath=in;
	string temp=inputFilePath;
	outputfilename="output_of_"+temp;
	paraOutfilename="paras_of_"+temp;
}
FileConverter::FileConverter(char *in,char *out){
	inputFilePath=in;
	outputfilename=out;
}
//use user reentered input file name to generate
void FileConverter::generateGraphParaFile(char *input_file_name){
	inputFilePath=input_file_name;
	generateGraphParaFile();

}
//use user default input file name to generate
void FileConverter::generateGraphParaFile(){
	string word,parameterStr,para2,para3,para4,para5, header, end;
	const string para1="frect",para6="10",para7="255",para8="10";
	int beginNum,endNum,noOfWordsReaded=0,sequenceNo=0,geneTwoSeqNO;
	const int geneOneLocation=2,geneTwoLocation=5,seqStartLocation=9,NOofWordsInALine=9;

	ifstream in(inputFilePath);
	//ofstream out("123.txt");
	ofstream out(paraOutfilename.c_str());

	//header = "new"; //+"size 1000,500"+"fill 1,1,255,255,255";
	out<<"new"<<"\n";
	out<<"size 1300,300"<<"\n";
	out<<"fill 1,1,255,255,255"<<"\n";
	out<<"line 45,0,45,500,10,10,10"<<"\n";
	out<<"line 46,0,46,501,10,10,10"<<"\n";
	out<<"string 10,1,1,10,30,small,CHR1"<<"\n";
	out<<"rect 10,47,30,230,10,10,10"<<"\n";
	out<<"fill 15,50,10,255,10"<<"\n";

	//write the name out
	out<<"string 10,1,1,60,30,small,CHR1"<<"\n";
	out<<"string 10,1,1,110,30,small,CHR2"<<"\n";
	out<<"string 10,1,1,160,30,small,CHR3"<<"\n";
	out<<"string 10,1,1,210,30,small,CHR4"<<"\n";
	out<<"string 10,1,1,260,30,small,CHR5"<<"\n";
	out<<"string 10,1,1,310,30,small,CHR6"<<"\n";
	out<<"string 10,1,1,360,30,small,CHR7"<<"\n";
	out<<"string 10,1,1,410,30,small,CHR8"<<"\n";
	out<<"string 10,1,1,460,30,small,CHR9"<<"\n";
	out<<"string 10,1,1,510,30,small,CHR10"<<"\n";
	out<<"string 10,1,1,560,30,small,CHR11"<<"\n";
	out<<"string 10,1,1,610,30,small,CHR12"<<"\n";
	out<<"string 10,1,1,660,30,small,CHR13"<<"\n";
	out<<"string 10,1,1,710,30,small,CHR14"<<"\n";
	out<<"string 10,1,1,760,30,small,CHR15"<<"\n";
	out<<"string 10,1,1,810,30,small,CHR16"<<"\n";
	out<<"string 10,1,1,860,30,small,CHR17"<<"\n";
	out<<"string 10,1,1,910,30,small,CHR18"<<"\n";
	out<<"string 10,1,1,960,30,small,CHR19"<<"\n";
	out<<"string 10,1,1,1010,30,small,CHR20"<<"\n";
	out<<"string 10,1,1,1060,30,small,CHR21"<<"\n";
	out<<"string 10,1,1,1110,30,small,CHR22"<<"\n";
	out<<"string 10,1,1,1160,30,small,CHR23"<<"\n";
	out<<"string 10,1,1,1210,30,small,CHR24"<<"\n";
	out<<"string 10,1,1,1260,30,small,CHR25"<<"\n";

	//draw the rect
	out<<"rect 60,47,80,230,10,10,10"<<"\n";
	out<<"rect 110,47,130,200,10,10,10"<<"\n";
	out<<"rect 160,47,180,180,10,10,10"<<"\n";
	out<<"rect 210,47,230,160,10,10,10"<<"\n";
	out<<"rect 260,47,280,220,10,10,10"<<"\n";
	out<<"rect 310,47,330,140,10,10,10"<<"\n";
	out<<"rect 360,47,380,245,10,10,10"<<"\n";
	out<<"rect 410,47,430,200,10,10,10"<<"\n";
	out<<"rect 460,47,480,150,10,10,10"<<"\n";
	out<<"rect 510,47,530,140,10,10,10"<<"\n";
	out<<"rect 560,47,580,145,10,10,10"<<"\n";
	out<<"rect 610,47,630,125,10,10,10"<<"\n";
	out<<"rect 660,47,680,120,10,10,10"<<"\n";
	out<<"rect 710,47,730,220,10,10,10"<<"\n";
	out<<"rect 760,47,780,140,10,10,10"<<"\n";
	out<<"rect 810,47,830,175,10,10,10"<<"\n";
	out<<"rect 860,47,880,225,10,10,10"<<"\n";
	out<<"rect,910,47,930,165,10,10,10"<<"\n";
	out<<"rect 960,47,980,158,10,10,10"<<"\n";
	out<<"rect 1010,47,1030,210,10,10,10"<<"\n";
	out<<"rect 1060,47,1080,90,10,10,10"<<"\n";
	out<<"rect 1110,47,1130,210,10,10,10"<<"\n";
	out<<"rect 1160,47,1180,125,10,10,10"<<"\n";
	out<<"rect 1210,47,1230,140,10,10,10"<<"\n";
	out<<"rect 1260,47,1280,120,10,10,10"<<"\n";

	while(in >> word){
		if (noOfWordsReaded%NOofWordsInALine==0)
			noOfWordsReaded=0;

		noOfWordsReaded+=1;
		if (noOfWordsReaded==geneTwoLocation){
			//read the number behind chr!
			geneTwoSeqNO=atoi(word.substr(3).c_str());

			para2=toString(61+(geneTwoSeqNO-1)*50);
			para4=toString(79+(geneTwoSeqNO-1)*50);

			//read next word after chr*
			in>>word; noOfWordsReaded+=1;
			beginNum=atoi(word.c_str());
			para3=toString(10+(int)(beginNum/1070000+40));

			//read next word after beginNum
			in>>word; noOfWordsReaded+=1;
			endNum=atoi(word.c_str());
			para5=toString(10+(int)(endNum/1070000+40));
			//para5=toString(11+(int)(beginNum/1070000));

			parameterStr=para1+" "+para2+","+para3+","+para4+","+para5+","+para6+","+para7+","+para8;
            //put the parameter strings into the output file 
			out<<parameterStr<<"\n";

		}
	}






}
void FileConverter::generateCompaireFile(){
	const int size=18000;//the size here may need be changed if you file size are large.... 
	char lineBuf[size];
	string lineStr;
	int noOfLineReaded=0;
	const int noOfLineInEachSeq=4;

	ifstream in(inputFilePath);
	ofstream out(outputfilename.c_str());

	while(in.getline(lineBuf,size)){
		noOfLineReaded+=1;
		if(noOfLineReaded%noOfLineInEachSeq==1){
			lineStr=lineBuf;
			 out<<lineStr<<"\n";
		}   
	}

}

void FileConverter::generateSequenceFile(){
  ifstream in(inputFilePath);
  string word,genePair,humanGeneStr,previousGeneTwo,
	     currentGeneTwo,outputFilename,animalGeneStr,
		 geneOneStr,geneTwoStr,nameOfGeneOne,nameOfGeneTwo,
		 subFolderName="Sequences_Files";
  int humanGeneNo=0,animalGeneNo=0,noOfWordsReaded=0,sequenceNo=0;
  const int geneOneLocation=2,geneTwoLocation=5,seqStartLocation=9;
  int genePairNo=0;

      while(in >> word){
		noOfWordsReaded+=1;
		if (noOfWordsReaded==geneOneLocation){
			nameOfGeneOne=word;
		}
		if (noOfWordsReaded==geneTwoLocation){
			nameOfGeneTwo=word;
		}
		if(previousGeneTwo!=nameOfGeneTwo){
				 sequenceNo=0;
				 previousGeneTwo=nameOfGeneTwo;
				 humanGeneNo=0;
				 animalGeneNo=0;
		}
		
		if (noOfWordsReaded==seqStartLocation){



			sequenceNo++;

		   	outputFilename=nameOfGeneOne+"-"+nameOfGeneTwo+"_"+toString(sequenceNo)+".txt";
	
			ofstream out(outputFilename.c_str());
			 in>>word;
			 humanGeneStr=word;
			 in>>word;
			 animalGeneStr=word;
			 currentGeneTwo=animalGeneStr;

			 string humanGeneNoStr,animalGeneNoStr,compareSymbol,humanGene,animalGene;
			 
			 for(int i=0;i<humanGeneStr.size();i++){
                 humanGene=humanGeneStr.at(i);
                 animalGene=animalGeneStr.at(i);
				 if (humanGene==animalGene){
					 ++humanGeneNo;
					 ++animalGeneNo;
					 humanGeneNoStr=toString(humanGeneNo);
					 animalGeneNoStr=toString(animalGeneNo);
					 compareSymbol="-";
				 }
				 else if (humanGene=="-"){
					 humanGeneNoStr="  ";
                     humanGene="|";
					 ++animalGeneNo;
					 animalGeneNoStr=toString(animalGeneNo);
					 compareSymbol=" ";
				 }
				 else if (animalGene=="-"){
					 animalGene="|";
					 ++humanGeneNo;
					 humanGeneNoStr=toString(humanGeneNo);
					 compareSymbol=" ";
				 } 
				 else {
					 ++humanGeneNo;
					 ++animalGeneNo;
					 humanGeneNoStr=toString(humanGeneNo);
					 animalGeneNoStr=toString(animalGeneNo);
					 compareSymbol=" ";
				 };
				 genePair=humanGeneNoStr+"  "+humanGene+" "+compareSymbol+" "+animalGene+" "+animalGeneNoStr;
		     	 
				 out<<genePair<<"\n";
			}	
			 noOfWordsReaded=0;
		}
		
	  }
	  
}
string FileConverter::toString(int num){
	strstream buf;
	string str;
	buf<<num;
	buf>>str;
	return str;  

}


Example for the data in the text file:
0 chr1 4557 4904 chr18 26128641 26128969 - 3997
1 chr1 5633 5822 chr18 26133554 26133742 - 6940
2 chr1 6710 6961 chr18 26136897 26137149 - 9591
3 chr1 7091 7238 chr18 26138722 26138869 - 8464
4 chr1 7458 7670 chr18 26138937 26139141 - 7255
5 chr1 7767 7942 chr18 26139575 26139746 - 7143
Last edited by LuciWiz : 03-Dec-2004 at 03:42. Reason: Please insert your c code between [c] & [/c] tags
  #2  
Old 06-Dec-2004, 02:40
vivina vivina is offline
New Member
 
Join Date: Dec 2004
Posts: 7
vivina is on a distinguished road
change my program abit
the picture that this program will draw
http://www.geocities.com/llxxivanxxll/pic.zip
CPP / C++ / C Code:
#include <string>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <strstream>
#include "FileConverter.h"
using namespace std;


FileConverter::FileConverter(char *in){
	inputFilePath=in;
	string temp=inputFilePath;
	outputfilename="output_of_"+temp;
	paraOutfilename="paras_of_"+temp;
}
FileConverter::FileConverter(char *in,char *out){
	inputFilePath=in;
	outputfilename=out;
}
//use user reentered input file name to generate
void FileConverter::generateGraphParaFile(char *input_file_name){
	inputFilePath=input_file_name;
	generateGraphParaFile();

}
//use user default input file name to generate
void FileConverter::generateGraphParaFile(){
	string word,parameterStr,para2,para3,para4,para5, header, end;
	const string para1="frect",para6="10",para7="255",para8="10";
	int beginNum,endNum,noOfWordsReaded=0,sequenceNo=0,geneTwoSeqNO;
	const int geneOneLocation=2,geneTwoLocation=5,seqStartLocation=9,NOofWordsInALine=9;

	ifstream in(inputFilePath);
	//ofstream out("123.txt");
	ofstream out(paraOutfilename.c_str());

	//header = "new"; //+"size 1000,500"+"fill 1,1,255,255,255";
	out<<"new"<<"\n";
	out<<"size 1300,300"<<"\n";
	out<<"fill 1,1,255,255,255"<<"\n";
	out<<"line 45,0,45,500,10,10,10"<<"\n";
	out<<"line 46,0,46,501,10,10,10"<<"\n";
	out<<"string 10,1,1,10,30,small,CHR1"<<"\n";
	out<<"rect 10,47,30,230,10,10,10"<<"\n";
	out<<"fill 15,50,10,255,10"<<"\n";

	//write the name out
	out<<"string 10,1,1,60,30,small,CHR1"<<"\n";
	out<<"string 10,1,1,110,30,small,CHR2"<<"\n";
	out<<"string 10,1,1,160,30,small,CHR3"<<"\n";
	out<<"string 10,1,1,210,30,small,CHR4"<<"\n";
	out<<"string 10,1,1,260,30,small,CHR5"<<"\n";
	out<<"string 10,1,1,310,30,small,CHR6"<<"\n";
	out<<"string 10,1,1,360,30,small,CHR7"<<"\n";
	out<<"string 10,1,1,410,30,small,CHR8"<<"\n";
	out<<"string 10,1,1,460,30,small,CHR9"<<"\n";
	out<<"string 10,1,1,510,30,small,CHR10"<<"\n";
	out<<"string 10,1,1,560,30,small,CHR11"<<"\n";
	out<<"string 10,1,1,610,30,small,CHR12"<<"\n";
	out<<"string 10,1,1,660,30,small,CHR13"<<"\n";
	out<<"string 10,1,1,710,30,small,CHR14"<<"\n";
	out<<"string 10,1,1,760,30,small,CHR15"<<"\n";
	out<<"string 10,1,1,810,30,small,CHR16"<<"\n";
	out<<"string 10,1,1,860,30,small,CHR17"<<"\n";
	out<<"string 10,1,1,910,30,small,CHR18"<<"\n";
	out<<"string 10,1,1,960,30,small,CHR19"<<"\n";
	out<<"string 10,1,1,1010,30,small,CHR20"<<"\n";
	out<<"string 10,1,1,1060,30,small,CHR21"<<"\n";
	out<<"string 10,1,1,1110,30,small,CHR22"<<"\n";
	out<<"string 10,1,1,1160,30,small,CHR23"<<"\n";
	out<<"string 10,1,1,1210,30,small,CHR24"<<"\n";
	out<<"string 10,1,1,1260,30,small,CHR25"<<"\n";

	//draw the rect
	out<<"rect 60,47,80,225,10,10,10"<<"\n";	//1
	out<<"rect 110,47,130,190,10,10,10"<<"\n";	//2
	out<<"rect 160,47,180,185,10,10,10"<<"\n";	//3
	out<<"rect 210,47,230,180,10,10,10"<<"\n";	//4
	out<<"rect 260,47,280,220,10,10,10"<<"\n";	//5
	out<<"rect 310,47,330,170,10,10,10"<<"\n";	//6
	out<<"rect 360,47,380,245,10,10,10"<<"\n";	//7
	out<<"rect 410,47,430,210,10,10,10"<<"\n";	//8
	out<<"rect 460,47,480,170,10,10,10"<<"\n";	//9
	out<<"rect 510,47,530,160,10,10,10"<<"\n";	//10
	out<<"rect 560,47,580,170,10,10,10"<<"\n";	//11
	out<<"rect 610,47,630,155,10,10,10"<<"\n";	//12
	out<<"rect 660,47,680,140,10,10,10"<<"\n";	//13
	out<<"rect 710,47,730,200,10,10,10"<<"\n";	//14
	out<<"rect 760,47,780,150,10,10,10"<<"\n";	//15
	out<<"rect 810,47,830,180,10,10,10"<<"\n";	//16
	out<<"rect 860,47,880,205,10,10,10"<<"\n";	//17
	out<<"rect,910,47,930,165,10,10,10"<<"\n";	//18
	out<<"rect 960,47,980,158,10,10,10"<<"\n";	//19
	out<<"rect 1010,47,1030,195,10,10,10"<<"\n";	//20
	out<<"rect 1060,47,1080,110,10,10,10"<<"\n";		//21
	out<<"rect 1110,47,1130,195,10,10,10"<<"\n";	//22
	out<<"rect 1160,47,1180,150,10,10,10"<<"\n";	//23
	out<<"rect 1210,47,1230,155,10,10,10"<<"\n";	//24
	out<<"rect 1260,47,1280,125,10,10,10"<<"\n";	//25

	while(in >> word){
		if (noOfWordsReaded%NOofWordsInALine==0)
			noOfWordsReaded=0;

		noOfWordsReaded+=1;
		if (noOfWordsReaded==geneTwoLocation){
			//read the number behind chr!
			geneTwoSeqNO=atoi(word.substr(3).c_str());

			//start drawing from x,y
			para2=toString(61+(geneTwoSeqNO-1)*50);
			para4=toString(79+(geneTwoSeqNO-1)*50);


			//read next word after chr*
			in>>word; noOfWordsReaded+=1;
			beginNum=atoi(word.c_str());
			para3=toString(10+(int)(beginNum/240000+40));

			//read next word after beginNum
			in>>word; noOfWordsReaded+=1;
			endNum=atoi(word.c_str());
			para5=toString(10+(int)(endNum/240000+40));
			//para5=toString(11+(int)(beginNum/1070000));

			parameterStr=para1+" "+para2+","+para3+","+para4+","+para5+","+para6+","+para7+","+para8;
            //put the parameter strings into the output file 
			out<<parameterStr<<"\n";

		}
	}






}
void FileConverter::generateCompaireFile(){
	const int size=2000;//the size here may need be changed if you file size are large.... 
	char lineBuf[size];
	string lineStr;
	int noOfLineReaded=0;
	const int noOfLineInEachSeq=4;

	ifstream in(inputFilePath);
	ofstream out(outputfilename.c_str());

	while(in.getline(lineBuf,size)){
		noOfLineReaded+=1;
		if(noOfLineReaded%noOfLineInEachSeq==1){
			lineStr=lineBuf;
			 out<<lineStr<<"\n";
		}   
	}

}

void FileConverter::generateSequenceFile(){
  ifstream in(inputFilePath);
  string word,genePair,humanGeneStr,previousGeneTwo,
	     currentGeneTwo,outputFilename,animalGeneStr,
		 geneOneStr,geneTwoStr,nameOfGeneOne,nameOfGeneTwo,
		 subFolderName="Sequences_Files";
  int humanGeneNo=0,animalGeneNo=0,noOfWordsReaded=0,sequenceNo=0;
  const int geneOneLocation=2,geneTwoLocation=5,seqStartLocation=9;
  int genePairNo=0;

      while(in >> word){
		noOfWordsReaded+=1;
		if (noOfWordsReaded==geneOneLocation){
			nameOfGeneOne=word;
		}
		if (noOfWordsReaded==geneTwoLocation){
			nameOfGeneTwo=word;
		}
		if(previousGeneTwo!=nameOfGeneTwo){
				 sequenceNo=0;
				 previousGeneTwo=nameOfGeneTwo;
				 humanGeneNo=0;
				 animalGeneNo=0;
		}
		
		if (noOfWordsReaded==seqStartLocation){



			sequenceNo++;

		   	outputFilename=nameOfGeneOne+"-"+nameOfGeneTwo+"_"+toString(sequenceNo)+".txt";
	
			ofstream out(outputFilename.c_str());
			 in>>word;
			 humanGeneStr=word;
			 in>>word;
			 animalGeneStr=word;
			 currentGeneTwo=animalGeneStr;

			 string humanGeneNoStr,animalGeneNoStr,compareSymbol,humanGene,animalGene;
			 
			 for(int i=0;i<humanGeneStr.size();i++){
                 humanGene=humanGeneStr.at(i);
                 animalGene=animalGeneStr.at(i);
				 if (humanGene==animalGene){
					 ++humanGeneNo;
					 ++animalGeneNo;
					 humanGeneNoStr=toString(humanGeneNo);
					 animalGeneNoStr=toString(animalGeneNo);
					 compareSymbol="-";
				 }
				 else if (humanGene=="-"){
					 humanGeneNoStr="  ";
                     humanGene="|";
					 ++animalGeneNo;
					 animalGeneNoStr=toString(animalGeneNo);
					 compareSymbol=" ";
				 }
				 else if (animalGene=="-"){
					 animalGene="|";
					 ++humanGeneNo;
					 humanGeneNoStr=toString(humanGeneNo);
					 compareSymbol=" ";
				 } 
				 else {
					 ++humanGeneNo;
					 ++animalGeneNo;
					 humanGeneNoStr=toString(humanGeneNo);
					 animalGeneNoStr=toString(animalGeneNo);
					 compareSymbol=" ";
				 };
				 genePair=humanGeneNoStr+"  "+humanGene+" "+compareSymbol+" "+animalGene+" "+animalGeneNoStr;
		     	 
				 out<<genePair<<"\n";
			}	
			 noOfWordsReaded=0;
		}
		
	  }
	  
}
string FileConverter::toString(int num){
	strstream buf;
	string str;
	buf<<num;
	buf>>str;
	return str;  

}

  #3  
Old 06-Dec-2004, 11:22
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
Have you tried running it through the debugger? You really need to be more specific as to what your problem is, and instead of supplying your entire source code, give us the code that pertains to the problem and let us know what kind of errors (assuming these are logic errors, not compiler errors) you are running into. If I were you, I'd be looking at the data as it is read from the file and before it undergoes the conversion that you are performing. Do a step by step and watch it perform each task at least once so that you can understand what is happening to the data as it is processed.

On a side note, I noticed that you are not testing most of your file I/O to see if it succeeded. While Stream I/O does protect you a bit more than low level and standard I/O, you still absolutely need to check to see if a file operation succeeded before you process any data. As I have said in a previous file I/O thread, a program that fails to test ALL file I/O operations is doomed to fail.
__________________
-Aaron
  #4  
Old 06-Dec-2004, 18:25
vivina vivina is offline
New Member
 
Join Date: Dec 2004
Posts: 7
vivina is on a distinguished road
ohh anyway i manage to get it running now....
thx aaroncohn for the advice...

anybody noe how to do filtering/windowing to filter out the data i want??
  #5  
Old 07-Dec-2004, 22:57
vivina vivina is offline
New Member
 
Join Date: Dec 2004
Posts: 7
vivina is on a distinguished road

Need Help Again!!


how do i pass the data from this beginNum & endNum to
CPP / C++ / C Code:
				in>>word; noOfWordsReaded+=1;
				beginNum=atoi(word.c_str());
				para3=toString(80+(int)(beginNum/240000));

			//read next word after beginNum
				in>>word; noOfWordsReaded+=1;
				endNum=atoi(word.c_str());
				para5=toString(80+(int)(endNum/240000));

this function's beginNum & endNum??
CPP / C++ / C Code:

void FileConverter::calculatePercent(int *endNum, int *beginNum)
	{
	int calculate;
	calculate=((endNum-beginNum)/100);
	cout<<calculate;

	}
  #6  
Old 08-Dec-2004, 11:33
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
You must pass the address of the variables.

The function call would look like...

CPP / C++ / C Code:
calculatepercent(&endNum, &beginNum);
__________________
-Aaron
  #7  
Old 09-Dec-2004, 01:30
vivina vivina is offline
New Member
 
Join Date: Dec 2004
Posts: 7
vivina is on a distinguished road
hmm got abit of prob doing that.... but nvm i put tat calculation part into the same function....
But now i got 1 prob.. when i use the calculate = endNum-beginNum
den when it check and loop but its not wat i wanted.... so how can i make sure that the para3=.......beginNum & endNum is the 1 i wanted from calculate=endNum - beginNum??

CPP / C++ / C Code:
calculate=endNum-beginNum;
if (calculate>=500)

{
para3=toString(80+(int)(beginNum/240000));
para5=toString(80+(int)(endNum/240000));
parameterStr=para1+","+para2+","+para3+","+para4+","+para5+","+para6+","+para7+","+para8;
out<<parameterStr<<"\n";
} 
  #8  
Old 09-Dec-2004, 03:14
aaroncohn's Avatar
aaroncohn aaroncohn is offline
Regular Member
 
Join Date: Feb 2004
Location: Bay Area, CA.
Posts: 564
aaroncohn is a jewel in the roughaaroncohn is a jewel in the roughaaroncohn is a jewel in the rough
Sorry, I'm not sure what you're trying to do with the function, nor am I seeing any kind of a loop. You did mention a loop, didn't you?
__________________
-Aaron
  #9  
Old 09-Dec-2004, 18:28
vivina vivina is offline
New Member
 
Join Date: Dec 2004
Posts: 7
vivina is on a distinguished road
well u see i need to calculate the difference between the endNum and the beginNum then i need to see if it's more then 50% if it is i will then draw a line..If it's lesser den 50% i dun draw...
overall i need to filter the result then draw a line...
below is basically what i use to draw rectangle and line..
CPP / C++ / C Code:
//use user default input file name to generate
void FileConverter::generateGraphParaFile(){
	string word,parameterStr,para2,para3,para4,para5, header, end;
	const string para1="frect",para6="10",para7="255",para8="10";
	int noOfWordsReaded=0,sequenceNo=0,geneTwoSeqNO,calculate,beginNum,endNum;
	const int geneOneLocation=2,geneTwoLocation=5,seqStartLocation=9,NOofWordsInALine=9;

	ifstream in(inputFilePath);
	ofstream out(paraOutfilename.c_str());

	out<<"new"<<"\n";
	out<<"size 1300,300"<<"\n";
	out<<"fill 1,1,255,255,255"<<"\n";
	out<<"line 0,51,2000,51,10,10,10"<<"\n";
	out<<"line 0,52,2000,52,10,10,10"<<"\n";
	out<<"string 10,1,1,5,25,small,CHR10"<<"\n";
	out<<"rect 40,20,606,40,10,10,10"<<"\n";

	//write the name out
	out<<"string 10,1,1,25,60,small,CHR1"<<"\n";
	out<<"string 10,1,1,75,60,small,CHR2"<<"\n";
	out<<"string 10,1,1,125,60,small,CHR3"<<"\n";
	out<<"string 10,1,1,175,60,small,CHR4"<<"\n";
	out<<"string 10,1,1,225,60,small,CHR5"<<"\n";
	out<<"string 10,1,1,275,60,small,CHR6"<<"\n";
	out<<"string 10,1,1,325,60,small,CHR7"<<"\n";
	out<<"string 10,1,1,365,60,small,CHR8"<<"\n";
	out<<"string 10,1,1,425,60,small,CHR9"<<"\n";
	out<<"string 10,1,1,475,60,small,CHR10"<<"\n";
	out<<"string 10,1,1,525,60,small,CHR11"<<"\n";
	out<<"string 10,1,1,575,60,small,CHR12"<<"\n";
	out<<"string 10,1,1,625,60,small,CHR13"<<"\n";
	out<<"string 10,1,1,675,60,small,CHR14"<<"\n";
	out<<"string 10,1,1,725,60,small,CHR15"<<"\n";
	out<<"string 10,1,1,775,60,small,CHR16"<<"\n";
	out<<"string 10,1,1,825,60,small,CHR17"<<"\n";
	out<<"string 10,1,1,875,60,small,CHR18"<<"\n";
	out<<"string 10,1,1,925,60,small,CHR19"<<"\n";
	out<<"string 10,1,1,975,60,small,CHR20"<<"\n";
	out<<"string 10,1,1,1025,60,small,CHR21"<<"\n";
	out<<"string 10,1,1,1075,60,small,CHR22"<<"\n";
	out<<"string 10,1,1,1125,60,small,CHR23"<<"\n";
	out<<"string 10,1,1,1175,60,small,CHR24"<<"\n";
	out<<"string 10,1,1,1225,60,small,CHR25"<<"\n";


	//draw the rect
	out<<"rect 25,77,45,255,10,10,10"<<"\n";	//1
	out<<"rect 75,77,95,220,10,10,10"<<"\n";	//2
	out<<"rect 125,77,145,215,10,10,10"<<"\n";	//3
	out<<"rect 175,77,195,210,10,10,10"<<"\n";	//4
	out<<"rect 225,77,245,250,10,10,10"<<"\n";	//5
	out<<"rect 275,77,295,200,10,10,10"<<"\n";	//6
	out<<"rect 325,77,345,275,10,10,10"<<"\n";	//7
	out<<"rect 375,77,395,240,10,10,10"<<"\n";	//8
	out<<"rect 425,77,445,200,10,10,10"<<"\n";	//9
	out<<"rect 475,77,495,190,10,10,10"<<"\n";	//10
	out<<"rect 525,77,545,200,10,10,10"<<"\n";	//11
	out<<"rect 575,77,595,185,10,10,10"<<"\n";	//12
	out<<"rect 625,77,645,170,10,10,10"<<"\n";	//13
	out<<"rect 675,77,695,230,10,10,10"<<"\n";	//14
	out<<"rect 725,77,745,180,10,10,10"<<"\n";	//15
	out<<"rect 775,77,795,210,10,10,10"<<"\n";	//16
	out<<"rect 825,77,845,235,10,10,10"<<"\n";	//17
	out<<"rect,875,77,895,195,10,10,10"<<"\n";	//18
	out<<"rect 925,77,945,188,10,10,10"<<"\n";	//19
	out<<"rect 975,77,995,225,10,10,10"<<"\n";	//20
	out<<"rect 1025,77,1045,140,10,10,10"<<"\n";	//21
	out<<"rect 1075,77,1095,225,10,10,10"<<"\n";	//22
	out<<"rect 1125,77,1145,180,10,10,10"<<"\n";	//23
	out<<"rect 1175,77,1195,185,10,10,10"<<"\n";	//24
	out<<"rect 1225,77,1245,155,10,10,10"<<"\n";	//25
	while(in >> word){
		if (noOfWordsReaded%NOofWordsInALine==0)
			noOfWordsReaded=0;

		noOfWordsReaded+=1;
	//draw chromosome 1(human)
		if (noOfWordsReaded==geneOneLocation){
			//read the number behind chr!
			geneTwoSeqNO=atoi(word.substr(3).c_str());

			//start drawing from x,y
			para3=toString(21);
			para5=toString(39);

		
			//read next word after chr*
			in>>word; noOfWordsReaded+=1;
			beginNum=atoi(word.c_str());
			para2=toString(41+(int)(beginNum/240000));

			//read next word after beginNum
			in>>word; noOfWordsReaded+=1;
			endNum=atoi(word.c_str());
			para4=toString(41+(int)(endNum/240000));

			parameterStr=para1+" "+para2+","+para3+","+para4+","+para5+","+para6+","+para7+","+para8;
           	out<<parameterStr<<"\n";	//put the parameter strings into the output file 
		}

//draw zebrafish chromosome
		else if (noOfWordsReaded==geneTwoLocation){
			//read the number behind chr!
			geneTwoSeqNO=atoi(word.substr(3).c_str());

			//start drawing from x,y
			para2=toString(26+(geneTwoSeqNO-1)*50);
			
			if (para2!="11") 
			{
				para4=toString(44+(geneTwoSeqNO-1)*50);
	
				//read next word after chr*
				in>>word; noOfWordsReaded+=1;
				beginNum=atoi(word.c_str());

				//read next word after beginNum
				in>>word; noOfWordsReaded+=1;
				endNum=atoi(word.c_str());
				
				
				calculate=endNum-beginNum;		
				if (calculate>=500)
					{
					para3=toString(80+(int)(beginNum/240000));
					para5=toString(80+(int)(endNum/240000));
				
					}

				parameterStr=para1+","+para2+","+para3+","+para4+","+para5+","+para6+","+para7+","+para8;
				out<<parameterStr<<"\n";	//put the parameter strings into the output file 
					
			}

		}
	}


}


But the if(calculate>=600) got some prob.. it end up filtering away those lines that is less then 600, but if i change the 600 to 400 it end up drawing all the lines.
sorry if u don't understand what i'm talking about....
  #10  
Old 13-Dec-2004, 23:58
vivina vivina is offline
New Member
 
Join Date: Dec 2004
Posts: 7
vivina is on a distinguished road

need serious HELP here!!


for example i set para as color and print out the color
CPP / C++ / C Code:
const string para6="10",para7="255", para8="10";
parameterStr=para6+" "+para7+" "+para8;

then now i want to put in a switch/if loop to change the para6,7,8
how do i do it??? got different color..
 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with coding expectation maximization needed. thanks edge C Programming Language 8 08-Nov-2005 05:00
PHP/MySQL coding issue cmarti MySQL / PHP Forum 3 26-Jul-2004 08:01
Need a little coding help dabigmooish C Programming Language 5 27-May-2004 23:37
Pls help in this coding. harsha CPP / C++ Forum 5 08-Apr-2004 20:48
coding a word with a givin factor funnyf CPP / C++ Forum 2 13-Jan-2004 08:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:26.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.