from Client0 import Client PRACTICE = 2 EXERCISE = 4 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") IP = "127.0.0.1" PORT = 8083 c = Client(IP, PORT) print(c.debug_talk("MESSAGE 1----")) print(c.debug_talk("MESSAGE 2: TESTING !!!"))
file = "../DNA Files/" extension = ".txt" dna = 'FRAT1' # -- Create a client object c = Client(ip, port) # -- Print the IP and PORTs print(c) # -- Read the Gene from a file s = Seq().read_fasta(file + dna + extension) # -- Send the Gene c.debug_talk(f"Sending {dna} Gene to the server...") c.debug_talk(str(s)) bases = str(s) # -- Print the Gene on the console print(f"Gene {dna}: {bases}") length = 10 c.talk(f"Sending {dna} Gene to the server, in fragments of {length} bases...") for i in range(5): frag = bases[i*length:(i+1)*length]
from Client0 import Client PRACTICE = 2 EXERCISE = 4 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") # -- Parameters of the server to talk to IP = "192.168.1.42" PORT = 8080 # -- Create a client object c = Client(IP, PORT) print(c) # -- Send a message to the server c.debug_talk("Message 1---") c.debug_talk("Message 2: Testing !!!")
from Client0 import Client PORT = 8080 IP = "127.0.0.1" for i in range(5): c = Client(IP, PORT) c.debug_talk(f"Message {i}")
from Client0 import Client from pathlib import Path import colorama PRACTICE = 2 EXERCISE = 5 print(f"-------|PRACTICE {PRACTICE}, EXERCISE {EXERCISE}|-------") IP = "127.0.0.1" PORT = 12000 c = Client(IP, PORT) colorama.init(strip='False') print(c.debug_talk("Sending the U5 gene to the server...")) print(c.debug_talk(Path("U5.txt").read_text()))
from Client0 import Client from Seq1 import Seq IP = "127.0.0.1" PORT = 8080 FOLDER = "../Session-04/" GENE = "U5" c = Client(IP, PORT) print(c) s = Seq("").read_fasta(FOLDER + GENE) c.debug_talk(f"Sending {GENE} gene to the server") c.debug_talk(str(s))
from Client0 import Client from Seq1 import Seq PRACTICE = 2 EXERCISE = 5 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") gene = "U5" folder = "../Session-04/" filename = folder + gene + ".txt" s = Seq("") # -- Initialize the null seq with the given file in fasta format s = str(s.read_fasta(filename)) # -- Parameters of the server to talk to IP = "127.0.0.1" PORT = 8081 # -- Create a client object c = Client(IP, PORT) c.debug_talk(f"Sending {gene} gene to the server...") c.debug_talk(s)
# -- We create a list of client objects, corresponding to the servers which we are going to interact to: clientlist = [] clientlist.append(c1) clientlist.append(c2) msg = "Sending FRAT1 Gene to the server, in fragments of 10 bases..." # -- We send the first message and the full body to both servers: for client in clientlist: response = client.debug_talk(msg) print(client) snull = Seq() print(f"Gene FRAT1: {dnabody}") for seq in allfragments: print(f"Fragment {allfragments.index(seq) + 1}: {seq}") # -- Odd elements go to server 1: for seq in oddlist: response = c1.debug_talk(f"Fragment {allfragments.index(seq) + 1}: {seq}") # -- Even elements go to server 2: for seq in evenlist: response = c2.debug_talk(f"Fragment {allfragments.index(seq) + 1}: {seq}")
from Client0 import Client PORT = 8084 IP = "127.0.0.1" for number in range(5): connection = Client(IP, PORT) print("Message", connection.debug_talk(number))
from Client0 import Client from Seq1 import Seq PRACTICE = 2 EXERCISE = 5 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") IP = "192.168.1.40" PORT = 8080 c = Client(IP, PORT) #merges ip and port as c # -- message to and from the server c.debug_talk("Sending U5 Gene to the server...") #send first message FOLDER = "../Session-04/" file_name = FOLDER + "FRAT1.txt" s = Seq("") s = s.read_fasta(file_name) s = str(s) #fragment divider n = 10 for i in range(0, len(s), n): c.debug_talk(f"Gene FRAT1: {s} \nFragment 1: ") #send the gene to the server
from Client0 import Client from Seq1 import Seq import colorama import termcolor PRACTICE = 2 EXERCISE = 6 print(f"-------|PRACTICE {PRACTICE}, EXERCISE {EXERCISE}|-------") IP = "127.0.0.1" PORT = 12000 c = Client(IP, PORT) s = Seq() s.read_fasta("../SESSION 4/FRAT1.txt") count = 0 i = 0 while i < len(s.strbases) and count < 5: colorama.init(strip='False') fragment = s.strbases[i:i + 10] count += 1 i += 10 print("Fragment ", count, ": ", termcolor.colored(fragment, 'blue')) print(c.debug_talk(fragment))
import socket from Client0 import Client # SERVER IP, PORT PORT = 8070 IP = "127.0.0.1" c = Client(IP, PORT) for n in range(1,6): c.debug_talk(str(n))
from Client0 import Client from termcolor import colored PRACTICE = 2 EXERCISE = 4 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") # -- Parameters of the server to talk to PORT = 20000 IP = "127.0.0.1" # -- Create a client object c = Client(IP, PORT) print( c.debug_talk( colored( "Message sent from the Client to the server", "blue", )))
from Client0 import Client PORT = 8080 IP = "127.0.0.1" for i in range(5): c = Client(IP, PORT) c.debug_talk(f"Message{i}...")
from termcolor import colored from pathlib import Path PRACTICE = 2 EXERCISE = 5 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") # -- Parameters of the server to talk to IP = "192.168.1.213" PORT = 8080 # -- Create a client object c = Client(IP, PORT) #Reading text FILENAME = "U5.txt" file_contents = Path(FILENAME).read_text() lines = file_contents.split("\n") body = lines[1:] bodystr = " " bodystr = bodystr.join(body) # -- Send a message to the server print("Sending a message to the server...") response1 = "Sending gene U5" response2 = bodystr response_list = [response1, response2] for i in response_list: print("To server: ", colored(response1, "green"), "\n", "From server: ", c.debug_talk(i))
from Client0 import Client from Seq1 import Seq PRACTICE = 2 EXERCISE = 6 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") IP = "127.0.0.1" PORT = 8080 c = Client(IP, PORT) print(c) s = Seq() s.read_fasta("../P0/Sequences/FRAT1.txt") # for i in range(0, 50, 10): # fragment = s.strbases[i:i+10] c.debug_talk("Sending the FRAT1 Gene to the server, in fragments of 10 bases...") count = 0 i = 0 while i < len(s.strbases) and count < 5: fragment = s.strbases[i:i + 10] count += 1 i += 10 c.debug_talk("Fragment " + str(count) + ": " + fragment)
from Client0 import Client from termcolor import colored PORT = 8081 IP = "212.128.253.169" s = Client(IP, PORT) for i in range(5): print('To Server:', colored(f'Message {i+1}', 'blue')) print(f'From Server:', s.debug_talk(colored(f'Message {i+1}', 'green')))
from Seq1 import Seq from Client0 import Client PRACTICE = 2 EXERCISE = 5 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") # -- Parameters of the server to talk to IP = "127.0.0.1" PORT = 8080 # -- Create a client object c = Client(IP, PORT) folder = "../Session-04/" s = Seq() sequence = s.read_fasta(folder + "U5.txt") c.debug_talk("Sending U5 Gene to the server...") c.debug_talk(str(sequence))
from Client0 import Client from Seq1 import Seq PRACTICE = 2 EXERCISE = 5 print("-----| Practice ", PRACTICE, "Exercise", EXERCISE, "|------") IP = "127.0.0.1" PORT = 8080 FOLDER = "../Session-04/" EXT = ".txt" GENE = "U5" filename = FOLDER + GENE + EXT # Create a client object c = Client(IP, PORT) # Print the IP and PORTs print(c) # Read the Gene from a file s = Seq().seq_read_fasta(filename) # Sending c.debug_talk("Sending " + GENE + " Gene to the server...") c.debug_talk(str(s))
from Client0 import Client PORT = 8080 IP = "192.168.1.105" for i in range(5): # -- Create a client object clnt = Client(IP, PORT) # -- Send a message to the server clnt.debug_talk(f"Message {i}")
from Client0 import Client IP = "192.168.8.108" PORT = 8080 # -- Create a client object c = Client(IP, PORT) print(c) counter = 0 while counter < 5: c.debug_talk(f"Message {counter}") counter += 1
from Client0 import Client PRACTICE = 2 EXERCISE = 6 print(f"----|Practice {PRACTICE}, Exercise {EXERCISE}|----") IP = "127.0.0.1" PORT = 12000 c = Client(IP, PORT) c.debug_talk("Message 1: This is my first message") c.debug_talk("Message 2: Testing...")
from Client0 import Client from Seq1 import Seq from Seq1 import * PRACTICE = 2 EXERCISE = 5 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") IP = "127.0.0.1" PORT = 2345 c = Client(IP, PORT) FOLDER = "../Session-04/" file = "U5.txt" s0 = Seq("").seq_read_fasta(FOLDER + file) m1 = "Sending u5 Gene to the server..." m2 = s0.__str__() c.debug_talk(m1) c.debug_talk(m2)
import colorama from colorama import Fore from Client0 import Client PRACTICE = 2 EXERCISE = 4 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") PORT = 12006 IP = "212.128.253.130" c = Client(IP, PORT) colorama.init() answer_one = c.debug_talk(Fore.BLUE + "Message 1---") print(Fore.YELLOW + answer_one) answer_two = c.debug_talk(Fore.BLUE + "Message 2: Testing !!!") print(Fore.YELLOW + answer_two)
from Client0 import Client from pathlib import Path print("---|PRACTICE 2: EXERCISE 5|---") IP = "127.0.0.1" PORT = 12000 c = Client(IP, PORT) c.debug_talk("Sending the U5 gene to the server...") c.debug_talk(Path("./Sequences/U5.txt").read_text())
from Client0 import Client IP = "192.168.1.52" PORT = 8080 c = Client(IP, PORT) print(c) print("Sending a message to the server...") msg_num = 0 for i in range(5): msg_num += 1 c.debug_talk(f"Message {msg_num}")
from Client0 import Client from Seq1 import Seq PRACTICE = 2 EXERCISE = 5 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") FOLDER = "../Session-04/" FILENAME = "U5.txt" # -- Parameters of the server to talk to IP = "127.0.0.1" PORT = 8080 # -- Create a client object c = Client(IP, PORT) # -- Print the IP and PORTs print(c) s = Seq().read_fasta(FOLDER + FILENAME) # -- Send the Gene c.debug_talk(f"Sending ยจ{FILENAME} Gene to the server...") c.debug_talk(str(s)) # First we have to launch the Teacher's server of Session-08 (server.py). Then execute the EX3.py program.
from Client0 import Client from Seq2 import Seq print("---|PRACTICE 2: EXERCISE 6|---") IP = "127.0.0.1" PORT = 12000 c = Client(IP, PORT) s = Seq() s.seq_read_fasta("./Sequences/FRAT1.txt") count = 0 i = 0 while i < len(s.strbases) and count < 5: fragment = s.strbases[i:i + 10] count += 1 i += 10 print("Fragment", count, ":", fragment) c.debug_talk(fragment)
bodystr = " " lines = file_contents.split('\n') body = lines[1:] msg2 = bodystr.join(body).replace(" ", "") PRACTICE = 2 EXERCISE = 5 print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------") # -- Parameters of the server to talk to IP = "212.128.253.169" PORT = 8080 # -- Create a client object c = Client(IP, PORT) msg1 = "Sending U5 Gene to the server..." # -- List of messages: msglist = [] msglist.append(msg1) msglist.append(msg2) # -- Each message will be sent, and the server will give us a response. for a in msglist: print(f"To Server: {colored(a, 'blue')}") response = c.debug_talk(a) print(f"From Server: {response}")
from Client0 import Client from Seq1 import Seq print(f"-----| Practice 2, Exercise 5 |------") IP = "127.0.0.1" PORT = 8080 c = Client(IP, PORT) FOLDER = "../Session_04/" GENE = "U5" EXT = ".txt" file_name = FOLDER + GENE + EXT sequence = Seq("") sequence = str(sequence.read_fasta(file_name)) c.debug_talk(f"Sending the {GENE} Gene to the server...") c.debug_talk(sequence)