예제 #1
0
from Client0 import Client

PRACTICE = 2
EXERCISE = 3

print(f"-------|PRACTICE {PRACTICE}, EXERCISE {EXERCISE}|-------")

IP = "127.0.0.1"
PORT = 12000
c = Client(IP, PORT)
response = c.talk("This is something random.")
print("Response : ", response)
예제 #2
0
from Client0 import Client
from pathlib import Path
PRACTICE = 2
EXERCISE = 5

print(f'------|PRACTICE {PRACTICE}, EXERCISE {EXERCISE} |--------')

IP = "127.0.0.1"
PORT = 12000
c = Client(IP, PORT)
print(c.talk('Sending the U5 Gene to the server...'))
print(c.talk(Path("./U5.txt").read_text()))
예제 #3
0
from Client0 import Client

print(f"-----| Practice 3, Exercise 7 |------")

IP = "127.0.0.1"
PORT = 8080

c = Client(IP, PORT)
print(c)

print("Testing PING...")
print(c.talk("PING"))

print("Testing GET...")
for i in range(5):
    print(c.talk(f'GET {i}'))

seq = c.talk("GET 0")
print("Testing INFO...")
print(c.talk(f"INFO {seq}"))

print("Testing COMP...")
print(c.talk(f"COMP {seq}"))

print("Testing REV...")
print(c.talk(f"REV {seq}"))

print("Testing GENE...")
for gene in ["U5", "ADA", "FRAT1", "FXN", "RNU6_269P"]:
    print(f"GENE {gene}")
    print(c.talk(f"GENE {gene}"))
예제 #4
0
from Client0 import Client

PRACTICE = 2
EXERCISE = 3

print(f'------|PRACTICE {PRACTICE}, EXERCISE {EXERCISE} |--------')

IP = "127.0.0.1"
PORT = 12000
c = Client(IP, PORT)
print('Response: ', c.talk('This is something random'))
예제 #5
0
from Client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 6

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")
IP = "127.0.0.1"
PORT = 2345
c = Client(IP, PORT)
FOLDER = "../Session-04/"
txt = ".txt"
gene = "FRAT1"
file_name = FOLDER + gene + txt

s0 = Seq('')
s0 = str(s0.seq_read_fasta(file_name))

size = 10
num_frag = 5
print(f"Gene {gene}: {s0}")
fragments = []
for e in range(num_frag):
    print(f"fragment {e+1}: {s0[size*e:size*(e+1)]}")
    fragments.append(s0[size*e:size*(e+1)])
for number in range(0,5):
    print(c.talk(fragments[number]))
예제 #6
0
from Seq1 import Seq
from Client0 import Client

PRACTICE = 2
EXERCISE = 6

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

folder = '../Session 4/'
gene = 'FRAT1.txt'
location = (folder + gene)
length = 10

PORT = 8081
IP = '192.168.0.13'

c = Client(IP, PORT)
print(c)

seq = Seq().read_fasta(location)
b_string = str(seq)
print(f"Gene {gene}: {b_string}")
c.talk(f"Gene {gene} win fragment of {length} elements: ")
for element in range(5):
    fragment = b_string[element * length:(element + 1) * length]
    print(f"Fragment{element+1}: {fragment}")
    c.talk(f"Fragment{element+1}: {fragment}")
예제 #7
0
from Client0 import Client
from Seq1 import Seq

IP = "127.0.0.1"
PORT = 8080

FOLDER = "../Session-04/"
EXT = ".txt"
GENE = "FRAT1"

c = Client(IP, PORT)

print(c)

s = Seq().read_fasta(FOLDER + GENE + EXT)
b = str(s)
print(f"Gene {GENE}: {b}")
length = 10
c.debug_talk(f"Sending {GENE} Gene to the server..., in fragments of {length}")
for i in range(5):
    fragm = b[i * length:(i + 1) * length]
    print(f"Fragment {i+10}: {fragm}")
    c.talk(f"Fragment {i+1}: {fragm}")
예제 #8
0
from Client0 import Client

print("-----| Practice 3, Exercise 7 |------")

ip = "192.168.1.39"
port = 8080

c = Client(ip, port)
print(c)

command0 = "GET 0"
gene0 = c.talk(command0)

print("Testing PING...")
print(c.talk("PING"))

print()
print("Testing GET...")

for i in range(5):
    command = f"GET {i}"
    print(f"{command}: {c.talk(command)}")

print()
print("Testing INFO...")
print(c.talk("INFO" + gene0))

print()
print("Testing COMP...")
print(c.talk("CONP" + gene0))
from Client0 import Client

PRACTICE = 3
EXERCISE = 7

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

PORT = 8080
IP = "127.0.0.1"

seq = ""
c = Client(IP, PORT)
print(c)
print("* Testing PING...")
print(Client.talk(c, "PING"))
print("* Testing GET...")
for i in range(0, 5):
    get = "GET " + str(i)
    print(get + ":", end=" ")
    print(Client.talk(c, get))
    if i == 0:
        seq = Client.talk(c, get)
print("* Testing INFO...")
print(Client.talk(c, "INFO " + seq))
print("* Testing COMP...")
print("COMP " + seq, Client.talk(c, "COMP " + seq))
print("* Testing REV...")
print("REV " + seq, Client.talk(c, "REV " + seq))
print("* Testing GENE...")
print("GENE U5", Client.talk(c, "GENE U5"))
print("GENE ADA", Client.talk(c, "GENE ADA"))
예제 #10
0
from Client0 import Client
from pathlib import Path

PRACTICE = 2
EXERCISE = 5

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

IP = "127.0.0.1"
PORT = 6123
c = Client(IP, PORT)
print(c.talk("Sending the U5 Gene to the serever..."))
print(c.talk(Path("./P2/U5.txt").read_text()))
예제 #11
0
from Client0 import Client

PRACTICE = 2
EXERCISE = 3

print(f"---- Practice {PRACTICE}, Exercise {EXERCISE} ----")

IP = '127.0.0.1'
PORT = 12000
c = Client(IP, PORT)
print('Response: ', c.talk('Hello this is random'))
예제 #12
0
print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

# -- Parameters
IP = "127.0.0.1"
PORT = 8080

# -- Create a client object
c = Client(IP, PORT)
sequence_test = "ACCTCCTCTCCAGCAATGCCAACCCCAGTCCAGGCCCCCATCCGCCCAGGATCTCGATCA"

print("Connection to SERVER at", IP, ", PORT: ", PORT)

# TEST PING
print("* Testing PING...")
print(c.talk("PING"))

# TEST GET
print("* Testing GET...")
print("GET 0:", c.talk("GET 0"))
print("GET 1:", c.talk("GET 1"))
print("GET 2:", c.talk("GET 2"))
print("GET 3:", c.talk("GET 3"))
print("GET 4:", c.talk("GET 4"))

# TEST INFO
print("* Testing INFO...")
print(c.talk("INFO " + sequence_test))

# TEST COMP
print("* Testing COMP...")
예제 #13
0
from Client0 import Client

PRACTICE = 2
EXERCISE = 4

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

IP = '127.0.0.1'
PORT = 6132
c = Client(IP, PORT)
print('Response: ', c.talk('Message'))
예제 #14
0
from Client0 import Client

c = Client('127.0.0.1', 8082)

print('Testing Ping...')
c.talk('PING')

print('Testing Get...')
for i in range(0, 5):
    msg = 'GET ' + str(i)
    c.talk(msg + '"')

print('Testing Info...')
c.talk('INFO ACTCGATCGAGCTGAGTCATCTAGCATCACAGT"')

print('Testing Comp...')
c.talk('COMP ACTCGATCGAGCTGAGTCATCTAGCATCACAGT"')

print('Testing Rev...')
c.talk('REV ACTCGATCGAGCTGAGTCATCTAGCATCACAGT"')

print('Testing Gene...')
gene_list = ['ADA', 'FRAT1', 'FXN', 'RNU6_269P', 'U5']
for gene in gene_list:
    msg = 'GENE ' + gene
    print('"' + msg + '"')
    c.talk(msg)
예제 #15
0
from Client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 6

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")
IP = "127.0.0.1"
PORT0 = 8099
PORT1 = 8098
c0 = Client(IP, PORT0)
c1 = Client(IP, PORT1)
FOLDER = "../Session-04/"
txt = ".txt"
gene = "FRAT1"
file_name = FOLDER + gene + txt
s0 = Seq('')
s0 = str(s0.read_fasta(file_name))
len0 = 10
num_frag = 10
print(f"Gene {gene}: {s0}")
for e in range(num_frag):
    print(f"fragment {e+1}: {s0[len0*e:len0*(e+1)]}")
    if (e + 1) % 2 == 0:
        c1.talk(f"fragment {e + 1}: {s0[len0*e:len0*(e + 1)]}")
    else:
        c0.talk(f"fragment {e+1}: {s0[len0*e:len0*(e+1)]}")
예제 #16
0
from Client0 import Client

IP = "127.0.0.1"
PORT = 8080

c = Client(IP, PORT)
print(c)

print("*Testing PING")
print(c.talk("PING"))

print()
print("*Testing GET")
for i in range(5):
    cmd = f"GET {i}"
    print("GET", i, ":", c.talk(cmd))

print()
print("*Testing INFO")
info = c.talk("GET 0")
cmd = f"INFO {info}"
print(c.talk(cmd))

print()
print("*Testing COMP")
comp = c.talk("GET 0")
cmd = f"COMP {comp}"
print(cmd)
print(c.talk(cmd))

print()
예제 #17
0
from Client0 import Client

print(f"-----| Practice 2, Exercise 3 |------")

IP = "127.0.0.1"
PORT = 8080

c = Client(IP, PORT)

print(c)
# -- Send a message to the server
print("Sending a message to the server...")
response = c.talk("Testing!!!")
print(f"Response: {response}")
예제 #18
0
from Client0 import Client

# -- Parameters of the server to talk to
IP = "127.0.0.1"
PORT = 8083

# -- Create a client object
c = Client(IP, PORT)
seq0 = "ACT"
print("-----| Practice 3, Exercise 7 |-----")

print("Testing PING...")
print(c.talk("PING"))

print("Testing GET...")
print(c.talk("GET 0"))
print(c.talk("GET 1"))
print(c.talk("GET 2"))
print(c.talk("GET 3"))
print(c.talk("GET 4"))

print("Testing INFO...")
print(c.talk(f"INFO {seq0}"))

print("Testing COMP...")
print(c.talk(f"COMP {seq0}"))

print("Testing REV...")
print(c.talk(f"REV {seq0}"))

print("Testing GENE...")
from Client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 6

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

IP = "127.0.0.1"
PORT = 12100

c = Client(IP, PORT)
s = Seq()
s.read_fasta("FRAT1")

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)
    print(c.talk(fragment))
예제 #20
0
# Creating fragments of length 10
frag1 = "Fragment 1: "
frag2 = "Fragment 2: "
frag3 = "Fragment 3: "
frag4 = "Fragment 4: "
frag5 = "Fragment 5: "
fragments = [frag1, frag2, frag3, frag4, frag5]

i = 0
f = 0
while f < 5:
    sequence = str(s)
    fragments[f] += sequence[i]
    i += 1
    if i % 10 == 0:
        f += 1

# connect
c = Client(IP, PORT)

c.talk(fragments[0])
c.talk(fragments[1])
c.talk(fragments[2])
c.talk(fragments[3])
c.talk(fragments[4])

# Print
print("Gene FRAT1:", s)
for frag in fragments:
    print(frag)
예제 #21
0
print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

FOLDER = "../Session-04/"
FILENAME = "FRAT1.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)
Bases = str(s)
print(f"Gene {FILENAME}: {Bases}")
length = 10  # Length of fragments

c.talk(
    f"Sending {FILENAME} Gene to the server, in fragments of {length} bases..."
)

for i in range(5):
    fragment = Bases[i * length:(i + 1) * length]

    print(f"Fragment {i + 1}: {fragment}")
    c.talk(f"Fragment {i + 1}: {fragment}")

# First we have to launch the Teacher's server of Session-08 (server.py). Then execute the EX3.py program.
예제 #22
0
from Client0 import Client
from pathlib import Path
PRACTICE = 2
EXERCISE = 4

print(f"----|Practice {PRACTICE}, Exercise {EXERCISE}|----")
IP = "192.168.0.241"
PORT = 139
c = Client(IP, PORT)
print(c.talk("Sending the  U5 gene to the server..."))
print(c.talk(Path("U5.txt").read_text()))
예제 #23
0
port2 = 8081

c1 = Client(ip, port1)
c2 = Client(ip, port2)

print(c1)
print(c2)

folder = "../Session-04/"
file = "FRAT1.txt"

seq = Seq().read_fasta(folder + file)

print(f"Gene FRAT1: {str(seq)}")

length = 10

mes = f"Sending FRAT1 gene to the server in fragments of {length} bases..."
c1.talk(mes)
c2.talk(mes)

print(f"Gene FRAT1: {str(seq)}")

for i in range(10):
    frag = str(seq)[i * length:(i + 1) * length]
    print(f"Fragment {i + 1}: {frag}")
    m = f"Fragment {i + 1}: {frag}"
    if i % 2:
        c2.talk(m)
    else:
        c1.talk(m)
예제 #24
0
from Client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 7

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

IP = "127.0.0.1"
PORT = 8081
PORT_2 = 8082
c = Client(IP, PORT)
c_2 = Client(IP, PORT_2)

s = Seq()
s.read_fasta('../Session-04/FRAT1.txt')
i = 0
count = 0
while i < len(s.strbases) and count < 10:
    fragment = s.strbases[i:i + 10]
    count += 1
    i += 10
    print('Fragment', count, ':', fragment)
    if count % 2 == 0:
        print(c_2.talk('Fragment ' + str(count) + ' : ' + fragment))
    else:
        print(c.talk('Fragment ' + str(count) + ' : ' + fragment))
예제 #25
0
from Client0 import Client

IP = "127.0.0.1"
PORT = 8080

c = Client(IP, PORT)
print(c)

print("Testing PING...")
print(c.talk("PING"))

print("Testing GET...")
for i in range(5):
    print(c.talk(f"GET {i}"))

print("Testing INFO...")
print(c.talk("INFO AACCGTA"))

print("Testing COMP...")
print(c.talk("COMP AACCGTA"))

print("Testing REV...")
print(c.talk("REV AACCGTA"))

print("Testing GENE...")
for gene in ["U5", "ADA", "FRAT1", "FXN", "RNU6_269P"]:
    print(f"GENE {gene}")
    print(c.talk(f"GENE {gene}"))
# -- CREATING
c = Client(IP, PORT)

print(c)

# -- MESSAGING

list1 = ["PING ", "GET ", "INFO ", "COMP ", "REV "]
sequence = "ACCTCCTCTCCAGCAATGCCAACCCCAGTCCAGGCCCCCATCCGCCCAGGATCTCGATCA"

for element in list1:
    print(f"*Testing {element}...")
    if element == "GET ":
        for i in range(0, 5):
            number = str(i)
            response = c.talk(element + number)
            print(f"GET {i}: {response}")
        print()
    else:
        if element != "PING " and element != "INFO ":
            print(f"{element} {sequence}")
        response = c.talk(element + sequence)
        print(response)
        print()

list2 = ["U5", "ADA", "FRAT1", "FXN", "RNU6_269P"]
print(f"*Testing GENE...")
a = "GENE "
for element in list2:
    print(a+element)
    response = c.talk(a+element)
예제 #27
0
from Client0 import Client

PRACTICE = 2
EXERCISE = 3

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")

IP = "127.0.0.1"
PORT = 8081
c = Client(IP, PORT)
response = c.talk("Message")
print("Response:", response)
예제 #28
0
from Client0 import Client
from pathlib import Path
PRACTICE = 2
EXERCISE = 5
print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")
IP = "192.168.1.54"
PORT = 8080
c = Client(IP, PORT)
print(c.talk('Sending the U5 gene to the server'))
print(c.talk(Path('U5.txt').read_text()))
예제 #29
0
FOLDER = "../Session-04/"
EXT = ".txt"
GENE = "FRAT1"
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)

# get the string
bases = str(s)

lenght = 10
c.talk(f"Sending {GENE} Gene to the server, in fragments of {lenght} bases...")

for i in range(5):
    # de 10 en 10
    fragment = bases[i * 10:(i + 1) * 10]

    # Print on Client's console
    print(f"Fragment {i + 1}: {fragment}")

    # Send the fragment to the server
    c.talk(f"Fragment {i + 1}: {fragment}")
예제 #30
0
# -- Create a client object
c1 = Client(IP, PORT1)
c2 = Client(IP, PORT2)
print(c1)
print(c2)

# -- Import the sequence
FOLDER = "../Session-04/"
FILENAME = "../Session-04/FRAT1.txt"
sequence = seq_read_fasta(FOLDER + FILENAME)

# -- Make the sequence into fragments and send it
new_seq = sequence[0:50]
string = ""
number = 1
c1.talk("Sending FRAT1 Gene to the server, in fragments of 10 bases...")
c2.talk("Sending FRAT1 Gene to the server, in fragments of 10 bases...")
print("Gene FRAT1: " + sequence)

# -- Make a list for the fragments
frag_list = []

new_seq = sequence[0:100]
string = ""
for element in new_seq:
    string = string + element
    if len(string) == 10:
        frag_list.append(string)
        print(string)
        string = ""