defblast_homo(self, blast, gff1, gff2, repeat_number): index = [group.sort_values(by=11, ascending=False)[:repeat_number].index.tolist() for name, group in blast.groupby([0])] blast = blast.loc[np.concatenate( np.array([k[:repeat_number] for k in index], dtype=object)), [0, 1]] blast = blast.assign(homo1=np.nan, homo2=np.nan, homo3=np.nan, homo4=np.nan, homo5=np.nan) for i in range(1, 6): bluenum = i+5 redindex = np.concatenate( np.array([k[:i] for k in index], dtype=object)) blueindex = np.concatenate( np.array([k[i:bluenum] for k in index], dtype=object)) grayindex = np.concatenate( np.array([k[bluenum:repeat_number] for k in index], dtype=object)) blast.loc[redindex, 'homo'+str(i)] = 1 blast.loc[blueindex, 'homo'+str(i)] = 0 blast.loc[grayindex, 'homo'+str(i)] = -1 return blast