def process_client(cs): # reading the message from the client msg = cs.recv(2048).decode("utf-8") msg = msg.split('\n') se = Seq(msg[0]) response = "" ac = "ACTG" if msg[0] == "asdf": response += "EMPTY" cs.send(str.encode(response)) nmbr = 0 for n in msg[0].upper(): if n in ac: nmbr += 1 if nmbr == len(msg[0]): response += "OK!" response += "\n" elif nmbr != len(msg[0]): response += "ERROR" cs.send(str.encode(response)) for i in msg[1:]: if i == 'len': response += se.len() elif i == 'complement': response += se.complement().strbases elif i == 'reverse': response += se.reversed().strbases elif i == 'countA': response += se.counting('A') elif i == 'countC': response += se.counting('C') elif i == 'countT': response += se.counting('T') elif i == 'countG': response += se.counting('G') elif i == 'percA': response += se.percentage('A') elif i == 'percC': response += se.percentage('C') elif i == 'percT': response += se.percentage('T') elif i == 'percG': response += se.percentage('G') # Sending the message back to the client # because we are an eco server cs.send(str.encode(response)) cs.close()
def comp(cs, argument): print_colored("COMP", "yellow") sequence = Seq(argument) comp = sequence.complement() cs.send(str(comp).encode()) return comp
def comp(argument): sequence = Seq(argument) comp = sequence.complement() return comp