Пример #1
0
from client0 import Client

PRACTICE = 2
EXERCISE = 3

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

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

c = Client(IP, PORT)
print('Response:', c.talk('Sending a message to the server...'))
Пример #2
0
from client0 import Client

PRACTICE = 2
EXERCISE = 3

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

PORT = 6123
IP = "127.0.0.1"
c = Client(IP, PORT)
print("Response: ", c.talk("Hello"))
Пример #3
0
from client0 import Client
from pathlib import Path
import termcolor
import colorama

PRACTICE = 2
EXERCISE = 5

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

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

c = Client(IP, PORT)
colorama.init(strip='False')
print('Response:', c.talk('Sending the U5 gene to the server...'))
print('From server:',
      c.talk(Path('U5.txt').read_text()))  #Leer el contenido de un FASTA FILE
Пример #4
0
    fragment1, fragment2, fragment3, fragment4, fragment5, fragment6,
    fragment7, fragment8, fragment9, fragment10
]

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

#connecting
c1 = Client(IP, PORT1)
c2 = Client(IP, PORT2)

r = 0
while r < len(fragments):
    if r % 2 == 0 or r == 0:
        c1.talk(fragments[r])
    else:
        c2.talk(fragments[r])

    r += 1

#print

print("Gene FRAT1:", s)
for frag in fragments:
    print(frag)
Пример #5
0
from client0 import Client
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.12"
PORT = 12000

# -- Create a client object
c = Client(IP, PORT)
print(c.talk("Sending the U5 Gene to the server..."))
print(c.talk(Path("U5.txt").read_text()))
Пример #6
0
from client0 import Client

PRACTICE = 2
EXERCISE = 1

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

IP = "127.0.0.1"
PORT = 12000
c = Client(IP, PORT)

print("Sending a message to the server...")
response = c.talk("Yes, this is working yuhuuuuu!!!")
print(response)
Пример #7
0
PRACTICE = 2
EXERCISE = 3

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

#Parameters of the server to talk to
IP = "127.0.0.1"
PORT = 12000
c = Client(IP, PORT)

s = Seq(
)  #Crea una null sequence - objeto, dentro del objeto se guardan .strbases y lo que haya en el innit
s.seq_read_fasta(
    '../Session-04/FRAT1.txt'
)  #usa un method de esa class, y lo que hace es leer un archivo FASTA quitandole la primera línea

count = 0
i = 0

while i < len(s.strbases) and count < 5:
    colorama.init(strip='False')
    fragment = s.strbases[i:i + 10]  #cogemos 10 bases
    count += 1
    i += 10
    print('Fragment', count, ':',
          termcolor.colored(fragment, 'green'))  #print en el client
    print(
        c.talk(
            termcolor.colored('Fragment ' + str(count) + ':' + fragment,
                              'green')))  #Para mandar los fragmentos al server
    #Dentro del loop que si no solo vamos a mandar el ult fragment
Пример #8
0
from client0 import Client

PRACTICE = 2
EXERCISE = 3

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

PORT = 6123
IP = "127.0.0.1"
c= Client(IP, PORT)
print(c.talk("Sending the U5 Gene to the server..."))
print(c.talk(Path("./P2/U5.txt").read_text()))     #We dont have this U5 so no working :/
print(c.talk(Path("U5.txt").read_text()))
Пример #9
0
PRACTICE = 2
EXERCISE = 1

from client0 import Client

PRACTICE = 2
EXERCISE = 3

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

# -- Parameters of the server to talk to
IP = "192.168.1.12"
PORT = 12000

# -- Create a client object
c = Client(IP, PORT)
print("Response;", c.talk("This is something random"))
Пример #10
0
EXT = ".txt"
GENE = "FRAT1"

c1 = Client(IP, PORT)
c2 = Client(IP, PORT + 1)

print(c1)
print(c2)
s = Seq().read_fasta(FOLDER + GENE + EXT)
bases = str(s)
print(f"Gene {GENE}: {bases}")
LENGTH = 10

init_msg = f"Sending {GENE} Gene to the server, in fragments of {LENGTH} bases..."

c1.talk(init_msg)
c2.talk(init_msg)

for i in range(10):

    frag = bases[i * LENGTH:(i + 1) * LENGTH]

    print(f"Fragment {i+1}: {frag}")

    msg = f"Fragment {i+1}: {frag}"

    if i % 2:
        c2.talk(msg)

    else:
        c1.talk(msg)
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):
    cmd = f"GET {i}"
    print(f"{cmd}: {c.talk(cmd)}", end="")

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

print("Testing COMP...")
cmd = f"COMP {seq}"
print(cmd, end="")
print(c.talk(cmd))

print("Testing REV...")
cmd = f"REV {seq}"
Пример #12
0
print("Practice 3, Exercise CLIENT SERVER")

# Parameters for the server
IP = "127.0.0.1"
PORT = 8080

# Creating a client object
c = Client(IP, PORT)
sequence = "GATGGATGGAGAGGATAGATAGAGATAGATAGAGAG"

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 COMP
print("* Testing COMP...")
Пример #13
0
from client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 6

print("-----| Practice ", PRACTICE, "Exercise ", EXERCISE, " |------")

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)
bases = str(s)

print(f"Gene {GENE}: {bases}")
LENGTH = 10

c.talk(f"Sending {GENE} Gene to the server, in fragments of {LENGTH} bases...")
for i in range(5):
    frag = bases[i * LENGTH:(i + 1) * LENGTH]
    print(f"Fragment {i+1}: {frag}")
    c.talk(f"Fragment {i+1}: {frag}")
Пример #14
0
from client0 import Client
from pathlib import Path
from Seq02 import Seq

PRACTICE = 2
EXERCISE = 6

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

# -- Parameters of the server to talk to
IP = "192.168.1.12"
PORT = 12000

# -- Create a client object
c = Client(IP, PORT)
s = Seq()
s.read_fasta("FRAT1.txt")
count = 0
for i in range(0, len(s.strbases), 10):
    fragment = s.strbases[i:i + 10]
    print(fragment)
    count = count + 1
    if count == 5:
        break
    print("Fragment", count, ":", fragment)
    print(c.talk(fragment))
Пример #15
0
from client0 import Client

print("Practice 2, Exercise 3")

#Parameters of the server to talk to
IP = "192.168.0.29"
PORT = 8080

#Create a client object
c = Client(IP, PORT)

#Send a message to the server
print("Sending a message to the server...")
response = c.talk("Testing!")
print(f"Response: {response}")
Пример #16
0
PORT = 8080  #El port no tiene que ser usado por ninguna aplicación más
IP = "localhost"

client = Client(IP, PORT)  #Client creado

correct = True
while correct:
    msg = input('Enter here the command you want to test: ').replace(
        ' ', '').upper()

    if msg == 'EXIT':
        print('The process has finished correctly.')
        correct = False

    elif msg == 'PING':
        client.talk(msg)

    elif msg == 'GET':
        for i in range(0, 5):
            client.talk(msg + ' ' + str(i))

    elif msg == 'INFO' or msg == 'COMP' or msg == 'REV':
        msg = msg + ' ' + str('AAACCCTTTT')  #client.talk('GET 0')
        client.talk(msg)

    elif msg == 'GENE':
        list_gene_names = ['U5', 'ADA', 'FRAT1', 'FXN', 'RNU6_269P']
        for i in list_gene_names:
            client.talk(msg + ' ' + str(i))

    else:
Пример #17
0
from client0 import Client

PRACTICE = 2
EXERCISE = 3

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

PORT = 6123
PORT2 = 12300
IP = "127.0.0.1"
c = Client(IP, PORT)
c_2 = Client(IP, PORT2)

s = Seq()
s.seq_read_fasta('../Session-04/FRAT!.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)
    if count % 2 == 0:
        print(c_2.talk("Fragment", str(count), ":", fragment))
    else:
        print(c.talk("Fragment", str(count), ":", fragment))
Пример #18
0
# Creating fragments of length 10
fragment1 = "Fragment 1: "
fragment2 = "Fragment 2: "
fragment3 = "Fragment 3: "
fragment4 = "Fragment 4: "
fragment5 = "Fragment 5: "
fragments = [fragment1, fragment2, fragment3, fragment4, fragment5]

i = 0
f = 0
while f < len(fragments):
    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)
Пример #19
0
from Seq1 import Seq
from client0 import Client

print("-----| Practice 3, Exercise 7 |------")
PORT = 8989
IP = "127.0.0.1"
c = Client(IP, PORT)
print(c)

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

print("* Testing GET...")
print(f"GET 0: {c.talk('GET 0')}")
print(f"GET 1: {c.talk('GET 1')}")
print(f"GET 2: {c.talk('GET 2')}")
print(f"GET 3: {c.talk('GET 3')}")
print(f"GET 4: {c.talk('GET 4')}")

print("* Testing INFO...")
print(c.talk('INFO ATTCGATGTGCTAGTCGATGCTGTGTACGTCAGTCAGTCGAT'))
print("* Testing COMP...")
print(c.talk('COMP ATTCGATGTGCTAGTCGATGCTGTGTACGTCAGTCAGTCGAT'))
print("* Testing REV...")
print(c.talk('REV ATTCGATGTGCTAGTCGATGCTGTGTACGTCAGTCAGTCGAT'))

print("* Testing GENE...")
print("GENE U5")
print(c.talk("GENE U5"))
print("GENE ADA")
print(c.talk("GENE ADA"))