Question
The server does not require a GUI and it does not have to handle multiple clients. It will construct the GenomeSearcher class, then proceed to
The server does not require a GUI and it does not have to handle multiple clients. It will construct the GenomeSearcher class, then proceed to wait for clients. Once a client connection is accepted it will follow these steps:
1.Read from the InputStream the string the client is sending
2.Pass the string to the GenomeSearcher class and receive a List
a.TIP: Before passing the string, I called geneString = str.replaceAll("\\s","");
i.This removes any accidental spaces, tabs or newline characters
ii.geneString is what I would pass to the GenomeSearcher, str is the input
3.Send the results back to the client
4.Close the connection
Communication Protocol
You may choose whatever you want to communicate between the server and client, so long as it works. If you are already familiar with XML, HTTP or JSON in Java then feel free to use those protocols. Personally I found it easy to work with Strings going back and forth. Figure 2 shows an example of the communication method I used.
By converting the Integers in the List to a String with appended to it, the client could call .readLine() to get the next value to place into the List. You do not have to follow this method, so long as what you utilize works.
For my example I used the IP address 127.0.0.1 to connect the client and server and port 1235 as it was open on my computer.You may want to try other ports, but the IP address should remain localhost (127.0.0.1).
General Advice
If you get an error from the server that it cannot bind that port or address because it is already in use, that means something is already connected to the IP/port combination you are using. If you accidentally left a copy of the server running in the background you may need to close down your IDE and re-open it. If the binding still fails, try a different port like 1236, 1237, 1238. It is also possible your firewall may prevent access though that is unlikely if you remain on the localhost IP.
PLAN OUT YOUR STEPS AND TEST AS YOU GO!
I cannot stress enough that you need to strategize on how you will tackle this project. Here are some steps I followed as an example:
1.Began with main function in the Server and an empty class for GenomeSearcher that Server constructed.
2.Coded the file read portion of the GenomeSearcher.
a.Verified the string length and subsections of the string made sense.
3.Coded the substring search portion of the GenomeSearcher.
a.Verified with a test call from Server that genes were being found.
b.The gene sequence for part of the ALU gene: "CCAAGGAGCTGGGACTACAG" should return 16 results.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started