data = """block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment2
block10_scaffold_1...alignment315
block10_scaffold_1...alignment665
block10_scaffold_1...alignment665
block10_scaffold_1...alignment665
block10_scaffold_1...alignment665
block10_scaffold_1...alignment665
block10_scaffold_1...alignment665
block10_scaffold_1...alignment665
block10_scaffold_1...alignment665
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment2
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664
block12_scaffold_1...alignment664"""
arr = dict()
for each in data.split("\n"):
a, b = each.split("...")
if a in arr:
arr[a][0] += 1
if(b in arr[a][1]):
arr[a][1][b] += 1
else:
arr[a][1][b] = 1
else:
arr[a] = [1, dict()]
arr[a][1][b] = 1
for each in arr.items():
key, res = each
a, b = res
print(f"{key} total: {a}", end = "\t")
ans = []
for elem in b.items():
k, v = elem
ans.append((k, v, v/a))
ans.sort(key = lambda x: x[2], reverse = True)
[print(f"{k} {v} {q: .4f}", end = "\t") for k, v, q in ans]
print()