管数版本
parent
0f0e2f9768
commit
338159b277
19
T7_client.py
19
T7_client.py
|
|
@ -23,7 +23,7 @@ def recvdata(conn, filepath):
|
||||||
recv_len += len(correntrecv)
|
recv_len += len(correntrecv)
|
||||||
|
|
||||||
|
|
||||||
def senddata(conn, path, chipum):
|
def senddata(conn, path, librarynum):
|
||||||
name = os.path.basename(os.path.realpath(path))
|
name = os.path.basename(os.path.realpath(path))
|
||||||
try:
|
try:
|
||||||
with open(path, 'rb') as file:
|
with open(path, 'rb') as file:
|
||||||
|
|
@ -31,7 +31,7 @@ def senddata(conn, path, chipum):
|
||||||
headerdic = dict(
|
headerdic = dict(
|
||||||
contentlen=len(content),
|
contentlen=len(content),
|
||||||
contentname=name,
|
contentname=name,
|
||||||
chipum=chipum
|
librarynum=librarynum
|
||||||
)
|
)
|
||||||
headerjson = json.dumps(headerdic)
|
headerjson = json.dumps(headerdic)
|
||||||
headerbytes = headerjson.encode('utf-8')
|
headerbytes = headerjson.encode('utf-8')
|
||||||
|
|
@ -51,9 +51,9 @@ def connect():
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
||||||
def transclient(sendfile, resfile, chipnum):
|
def transclient(sendfile, resfile, librarynum):
|
||||||
conn = connect()
|
conn = connect()
|
||||||
senddata(conn, sendfile, chipnum)
|
senddata(conn, sendfile, librarynum)
|
||||||
recvdata(conn, resfile)
|
recvdata(conn, resfile)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ def make_gui():
|
||||||
sg.theme('DarkBlack1')
|
sg.theme('DarkBlack1')
|
||||||
|
|
||||||
layout = [
|
layout = [
|
||||||
[sg.Text('排样芯片数'), sg.Spin([i for i in range(20)], initial_value=5, size=(3, 1), key='_CHIPNUM_')],
|
[sg.Text('排样管数'), sg.Spin([i for i in range(150)], initial_value=130, size=(3, 1), key='_LIBRARYNUM_')],
|
||||||
[sg.Text()],
|
[sg.Text()],
|
||||||
[
|
[
|
||||||
sg.Text('导入排样excel')],
|
sg.Text('导入排样excel')],
|
||||||
|
|
@ -75,16 +75,17 @@ def make_gui():
|
||||||
[sg.Text()],
|
[sg.Text()],
|
||||||
[
|
[
|
||||||
sg.OK('生成'), sg.Cancel('取消')]]
|
sg.OK('生成'), sg.Cancel('取消')]]
|
||||||
# iconpath = os.path.join(os.path.abspath(sys.path[0]), 'other', 'icon.ico')
|
iconpath = os.path.join(os.path.abspath(sys.path[0]), 'other', 'icon.ico')
|
||||||
window = sg.Window('解码排样T7程序', layout, font='Helvetica 11')
|
print(iconpath)
|
||||||
|
window = sg.Window('解码排样T7程序', layout, font='Helvetica 11', icon=r'D:\project\autulayout\other\icon.ico')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
event, values = window.Read()
|
event, values = window.read()
|
||||||
if event == '生成':
|
if event == '生成':
|
||||||
if not values['_FILE1_'] or not values['_FILE2_']:
|
if not values['_FILE1_'] or not values['_FILE2_']:
|
||||||
sg.popup_non_blocking('请正确提供参数')
|
sg.popup_non_blocking('请正确提供参数')
|
||||||
else:
|
else:
|
||||||
transclient(values['_FILE1_'], os.path.join(values['_FILE2_']), values['_CHIPNUM_'])
|
transclient(values['_FILE1_'], os.path.join(values['_FILE2_']), values['_LIBRARYNUM_'])
|
||||||
sg.Popup('排样成功!')
|
sg.Popup('排样成功!')
|
||||||
window.Close()
|
window.Close()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ def recvdata(conn, path):
|
||||||
header_dic = json.loads(header_json)
|
header_dic = json.loads(header_json)
|
||||||
content_len = header_dic['contentlen']
|
content_len = header_dic['contentlen']
|
||||||
content_name = header_dic['contentname']
|
content_name = header_dic['contentname']
|
||||||
chipnum = header_dic['chipnum']
|
librarynum = header_dic['librarynum']
|
||||||
recv_len = 0
|
recv_len = 0
|
||||||
fielpath = os.path.join(path, '%s_%s' % (datetime.now().strftime("%m%d%H%M"), content_name))
|
fielpath = os.path.join(path, '%s_%s' % (datetime.now().strftime("%m%d%H%M"), content_name))
|
||||||
file = open(fielpath, 'wb')
|
file = open(fielpath, 'wb')
|
||||||
|
|
@ -31,7 +31,7 @@ def recvdata(conn, path):
|
||||||
file.write(correntrecv)
|
file.write(correntrecv)
|
||||||
recv_len += len(correntrecv)
|
recv_len += len(correntrecv)
|
||||||
file.close()
|
file.close()
|
||||||
return fielpath, chipnum
|
return fielpath, librarynum
|
||||||
|
|
||||||
|
|
||||||
def senddata(conn, path, message=None):
|
def senddata(conn, path, message=None):
|
||||||
|
|
@ -77,8 +77,8 @@ def server():
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
myclient, adddr = myserver.accept()
|
myclient, adddr = myserver.accept()
|
||||||
recv_content, chipnum = recvdata(myclient, os.path.join(basedir, 'example'))
|
recv_content, librarynum = recvdata(myclient, os.path.join(basedir, 'example'))
|
||||||
layout = T7(recv_content, chipnum)
|
layout = T7(recv_content, librarynum)
|
||||||
outputpath = layout.run()
|
outputpath = layout.run()
|
||||||
senddata(myclient, outputpath)
|
senddata(myclient, outputpath)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ def senddata(conn, path, select_type):
|
||||||
def connect():
|
def connect():
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
dest_ip = '192.168.11.121'
|
dest_ip = '192.168.11.121'
|
||||||
dest_port = int(8190)
|
dest_port = int(8191)
|
||||||
client.connect((dest_ip, dest_port))
|
client.connect((dest_ip, dest_port))
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ def make_gui():
|
||||||
select_type = 'xplus'
|
select_type = 'xplus'
|
||||||
else:
|
else:
|
||||||
select_type = 't7'
|
select_type = 't7'
|
||||||
transclient(values['_FILE1_'], os.path.join(values['_FILE2_'], select_type))
|
transclient(values['_FILE1_'], os.path.join(values['_FILE2_']), select_type)
|
||||||
sg.Popup('排样成功!')
|
sg.Popup('排样成功!')
|
||||||
else:
|
else:
|
||||||
window.Close()
|
window.Close()
|
||||||
|
|
|
||||||
50
tools/t7.py
50
tools/t7.py
|
|
@ -14,10 +14,10 @@ class AutoLayout:
|
||||||
自动化派样
|
自动化派样
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, path, chipnum, output=basedir, data_limit=1750):
|
def __init__(self, path, librarynum, output=basedir, data_limit=1750):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.output = output
|
self.output = output
|
||||||
self.chipnum = int(chipnum)
|
self.librarynum = int(librarynum)
|
||||||
self.data_limit = data_limit
|
self.data_limit = data_limit
|
||||||
|
|
||||||
self.index_assignments = defaultdict(list)
|
self.index_assignments = defaultdict(list)
|
||||||
|
|
@ -67,13 +67,14 @@ class AutoLayout:
|
||||||
|
|
||||||
if newer:
|
if newer:
|
||||||
self.chip_size[chipname] = library_data['size']
|
self.chip_size[chipname] = library_data['size']
|
||||||
if library_data['classification'] in ['扩增子', '不平衡文库', '单细胞文库以及甲基化']:
|
# if library_data['classification'] in ['扩增子', '不平衡文库', '单细胞文库以及甲基化']:
|
||||||
|
if library_data['is_balance_lib'] == '否':
|
||||||
self.chip_speciallib_size[chipname] = library_data['size']
|
self.chip_speciallib_size[chipname] = library_data['size']
|
||||||
else:
|
else:
|
||||||
self.chip_speciallib_size[chipname] = 0
|
self.chip_speciallib_size[chipname] = 0
|
||||||
else:
|
else:
|
||||||
self.chip_size[chipname] += library_data['size']
|
self.chip_size[chipname] += library_data['size']
|
||||||
if library_data['classification'] in ['扩增子', '不平衡文库', '单细胞文库', '甲基化']:
|
if library_data['is_balance_lib'] == '否':
|
||||||
self.chip_speciallib_size[chipname] += library_data['size']
|
self.chip_speciallib_size[chipname] += library_data['size']
|
||||||
|
|
||||||
self.chip_customer[chipname].add(library_data['customer'])
|
self.chip_customer[chipname].add(library_data['customer'])
|
||||||
|
|
@ -182,6 +183,7 @@ class AutoLayout:
|
||||||
# customer = library_data['customer']
|
# customer = library_data['customer']
|
||||||
library = library_data['library']
|
library = library_data['library']
|
||||||
classification = library_data['classification']
|
classification = library_data['classification']
|
||||||
|
is_balance_lib = library_data['is_balance_lib']
|
||||||
|
|
||||||
# 芯片大小不能超过设定限制
|
# 芯片大小不能超过设定限制
|
||||||
sizelimit = True
|
sizelimit = True
|
||||||
|
|
@ -198,10 +200,9 @@ class AutoLayout:
|
||||||
if self.use_rule(chipname, classification):
|
if self.use_rule(chipname, classification):
|
||||||
exclusive_classific = False
|
exclusive_classific = False
|
||||||
|
|
||||||
# 不平衡文库大于200G 不能添加
|
# 不平衡文库大于250G 不能添加
|
||||||
splibrary = True
|
splibrary = True
|
||||||
if classification in ['扩增子', '不平衡文库', '单细胞文库', '甲基化'] \
|
if is_balance_lib == '否' and self.chip_speciallib_size[chipname] + size > 250:
|
||||||
and self.chip_speciallib_size[chipname] + size > 250:
|
|
||||||
splibrary = False
|
splibrary = False
|
||||||
|
|
||||||
# 碱基不平衡不过不添加,保证前面的数据, 在数据达到1200G的时候开始
|
# 碱基不平衡不过不添加,保证前面的数据, 在数据达到1200G的时候开始
|
||||||
|
|
@ -226,7 +227,7 @@ class AutoLayout:
|
||||||
ori_library_df = pd.DataFrame(self.ori_data['未测'])
|
ori_library_df = pd.DataFrame(self.ori_data['未测'])
|
||||||
|
|
||||||
need_col = ['#library', 'sublibrary', 'i5', 'i7', 'data_needed', 'real_data', 'customer',
|
need_col = ['#library', 'sublibrary', 'i5', 'i7', 'data_needed', 'real_data', 'customer',
|
||||||
'classification', 'priority', 'time', '拆分方式', 'barcode'
|
'classification', 'priority', 'time', '拆分方式', 'barcode', 'is_balance_lib'
|
||||||
]
|
]
|
||||||
get_col = set(ori_library_df.columns)
|
get_col = set(ori_library_df.columns)
|
||||||
unhave_col = set(need_col) - get_col
|
unhave_col = set(need_col) - get_col
|
||||||
|
|
@ -250,9 +251,38 @@ class AutoLayout:
|
||||||
# 使用布尔索引筛选出不是数字和非日期的行
|
# 使用布尔索引筛选出不是数字和非日期的行
|
||||||
ori_library_df = ori_library_df[(numeric_mask & time_mask)]
|
ori_library_df = ori_library_df[(numeric_mask & time_mask)]
|
||||||
ori_library_df['level'] = ori_library_df.apply(self.level, axis=1)
|
ori_library_df['level'] = ori_library_df.apply(self.level, axis=1)
|
||||||
|
|
||||||
|
# 极致客户有重复的,把等级调到0,防止放到了最后,到了未测里
|
||||||
|
duplicate_name = ori_library_df[ori_library_df['level'] == 2].duplicated(subset='barcode', keep=False)
|
||||||
|
# 将 'level' 列的值改为 0
|
||||||
|
ori_library_df.loc[duplicate_name, 'level'] = 0
|
||||||
|
|
||||||
for library, library_df in ori_library_df.groupby('#library'):
|
for library, library_df in ori_library_df.groupby('#library'):
|
||||||
|
|
||||||
|
size = library_df['data_needed'].sum()
|
||||||
|
|
||||||
|
flag = False
|
||||||
|
if size > (self.data_limit) / 2:
|
||||||
|
library_df['data_needed'] = library_df['data_needed'] / 2
|
||||||
|
flag = True
|
||||||
|
|
||||||
ori_library_data.append(dict(
|
ori_library_data.append(dict(
|
||||||
library=library,
|
library=library,
|
||||||
|
is_balance_lib=library_df['is_balance_lib'].values[0],
|
||||||
|
size=library_df['data_needed'].sum(),
|
||||||
|
split_method=library_df['拆分方式'].values[0],
|
||||||
|
time=library_df['time'].values[0],
|
||||||
|
level=library_df['level'].values[0],
|
||||||
|
customer=library_df['customer'].values[0],
|
||||||
|
classification=library_df['classification'].values[0],
|
||||||
|
data=library_df[need_col].to_dict('records')
|
||||||
|
))
|
||||||
|
|
||||||
|
if flag:
|
||||||
|
self.return_log.append(f'文库{library} 已做拆分处理, 请注意!!! ')
|
||||||
|
ori_library_data.append(dict(
|
||||||
|
library=library,
|
||||||
|
is_balance_lib=library_df['is_balance_lib'].values[0],
|
||||||
size=library_df['data_needed'].sum(),
|
size=library_df['data_needed'].sum(),
|
||||||
split_method=library_df['拆分方式'].values[0],
|
split_method=library_df['拆分方式'].values[0],
|
||||||
time=library_df['time'].values[0],
|
time=library_df['time'].values[0],
|
||||||
|
|
@ -309,12 +339,14 @@ class AutoLayout:
|
||||||
writer = pd.ExcelWriter(outputpath)
|
writer = pd.ExcelWriter(outputpath)
|
||||||
|
|
||||||
chip_loc = 1
|
chip_loc = 1
|
||||||
|
librarynum = 0
|
||||||
for chip_idx, chip_assignments in self.index_assignments.items():
|
for chip_idx, chip_assignments in self.index_assignments.items():
|
||||||
df = pd.DataFrame(chip_assignments)
|
df = pd.DataFrame(chip_assignments)
|
||||||
df['time'] = df['time'].dt.strftime('%Y-%m-%d')
|
df['time'] = df['time'].dt.strftime('%Y-%m-%d')
|
||||||
if df['data_needed'].sum() < 1500 or chip_loc > self.chipnum:
|
if df['data_needed'].sum() < 1600 or librarynum > self.librarynum:
|
||||||
self.no_assign_data.extend(df.to_dict('records'))
|
self.no_assign_data.extend(df.to_dict('records'))
|
||||||
continue
|
continue
|
||||||
|
librarynum += len(set(df['#library'].values))
|
||||||
if [method for method in df['拆分方式'].values if '极致' in method]:
|
if [method for method in df['拆分方式'].values if '极致' in method]:
|
||||||
addname = 'X'
|
addname = 'X'
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue