Esempio n. 1
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"))
Esempio n. 2
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))
Esempio n. 3
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()))
Esempio n. 4
0
from client0 import Client

PRACTICE = 2
EXERCISE = 1

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

PORT = 6123
IP = "127.0.0.1"
C = Client(IP, PORT)
C.advanced_ping()
Esempio n. 5
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"))
Esempio n. 6
0
from client0 import Client

PRACTICE = 2
EXERCISE = 4

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

IP = "127.0.0.1"
PORT = 8080
c = Client(IP, PORT)
print(c)
c.debug_talk("Message 1---")
c.debug_talk("Message 2: Testing !!!")
Esempio n. 7
0
from client0 import Client

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

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

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

#Print the IP and PORTs
print(c)
from client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 7

print(f"-----| Practice {PRACTICE}, Exercise {EXERCISE} |------")
IP = "127.0.0.1"
PORT = 8080

FOLDER = "../Session-04/"
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):
Esempio n. 9
0
from client0 import Client
from Seq1 import Seq
import termcolor
import colorama

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
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}"
Esempio n. 11
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"))
Esempio n. 12
0
from client0 import Client

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
Esempio n. 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}")
Esempio n. 14
0
from client0 import Client
import termcolor

PRACTICE = 2
EXERCISE = 3

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

PORT = 6123
IP = "127.0.0.1"
c= Client(IP, PORT)
print(c.debug_talk("Hello"))
Esempio n. 15
0
from client0 import Client

PRACTICE = 2
EXERCISE = 1

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

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

c.advanced_ping()
c.ping()
print(f"IP: {c.ip}, {c.port}")
Esempio n. 16
0
from client0 import Client
from pathlib import Path

PRACTICE = 2
EXERCISE = 1

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

IP = "127.0.0.1"
PORT = 12000
c = Client(IP, PORT)
print(c.debug_talk("Sending the U5 Gene to the server..."))
print()
print(c.debug_talk(Path("U5.txt").read_text()))
Esempio n. 17
0
fragments = [
    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:
Esempio n. 18
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}")
Esempio n. 19
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...'))
from client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 5

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

IP = "127.0.0.1"
PORT = 8080
c = Client(IP, PORT)
print(c)
FOLDER = "../Session-04/"
GENE = "U5"
EXT = ".txt"
s = Seq().read_fasta(FOLDER + GENE + EXT)
c.debug_talk(f"Sending {GENE} Gene to the server...")
c.debug_talk(str(s))
Esempio n. 21
0
from client0 import Client
from Seq1 import Seq

print("Practice 2, Exercise 5")

#Parameters
IP = "192.168.0.29"
PORT = 8080
FOLDER = "../Session-04/"
filename = FOLDER + 'U5.txt'
s = Seq()
s.read_fasta(filename)

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

c.debug_talk("Sending the U5 Gene to the server..")
c.debug_talk(s)
Esempio n. 22
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))
Esempio n. 23
0
from client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 1

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

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

s = Seq()
s.read_fasta('../Session-04/FRAT1.txt')
i = 0
count = 0
while i < len(s.str_bases) and count < 5:
    fragment = s.str_bases[i:i + 10]
    count += 1
    i += 10
    fragment_text = "Fragment " + str(count) + ":" + fragment
    print(fragment_text)
    print(c.debug_talk(fragment_text))
Esempio n. 24
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)
Esempio n. 25
0
from client0 import Client

PRACTICE = 2
EXERCISE = 1

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

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

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

# -- Test the ping method
c.ping()

# -- Print the IP and PORTs
print(f"IP: {c.ip}, {c.port}")
Esempio n. 26
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
Esempio n. 27
0
from client0 import Client

# SERVER IP, PORT
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:
from client0 import Client

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

# Repeat five times
for i in range(5):

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

    # Send a message to the server
    client.debug_talk(f"Message {i}")
Esempio n. 29
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)
Esempio n. 30
0
from client0 import Client
from Seq1 import Seq

PRACTICE = 2
EXERCISE = 1

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

IP = "127.0.0.1"
PORT = 12000
PORT_2 = 12002
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.str_bases) and count < 10:
    fragment = s.str_bases[i:i + 10]
    count += 1
    i += 10
    fragment_text = "Fragment " + str(count) + ": " + fragment
    print(fragment_text)
    if count % 2 == 0:
        print(c_2.debug_talk(fragment_text))
    else:
        print(c.debug_talk(fragment_text))