Spaces:
Sleeping
Sleeping
File size: 1,860 Bytes
c2a02c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
def get_interface_positions(dataframe, column1, column2):
interface_positions = {}
for i in dataframe.index:
if dataframe.at[i, column1] not in interface_positions and dataframe.at[i, column1 + '_IRES'] != '[]':
interface_positions[dataframe.at[i, column1]] = dataframe.at[i, str(column1 + '_IRES')]
elif dataframe.at[i, column1] in interface_positions and dataframe.at[i, column1 + '_IRES'] != '[]':
interface_positions[dataframe.at[i, column1]] = interface_positions[dataframe.at[i, column1]].strip(
']') + ',' + (dataframe.at[i, str(column1 + '_IRES')]).strip('[')
if dataframe.at[i, column2] not in interface_positions and dataframe.at[i, column2 + '_IRES'] != '[]':
interface_positions[dataframe.at[i, column2]] = dataframe.at[i, str(column2 + '_IRES')]
elif dataframe.at[i, column2] in interface_positions and dataframe.at[i, column2 + '_IRES'] != '[]':
interface_positions[dataframe.at[i, column2]] = interface_positions[dataframe.at[i, column2]].strip(
']') + ',' + (dataframe.at[i, str(column2 + '_IRES')]).strip('[')
try:
for key, value in interface_positions.items():
n = []
m = []
if value != '[]':
valueList = value.split(',')
valueList[0] = str(valueList[0]).strip('[')
valueList[-1] = str(valueList[-1]).strip(']')
for val in valueList:
if '-' in val:
for r in range(int(val.split('-')[0]), int(val.split('-')[1]) + 1):
n.append(r)
else:
m.append(int(val))
fin = m + n
interface_positions[key] = fin
except:
ValueError
return interface_positions
|