Skip to content

Commit

Permalink
Create PDST
Browse files Browse the repository at this point in the history
  • Loading branch information
poddarharsh15 authored Dec 16, 2019
1 parent eb7de3a commit be64763
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions PDST
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def p_distance(DNA1,DNA2):
diff = 0
for i in range(len(DNA1)):
if DNA1[i] != DNA2[i]:
diff += 1
return "%.5f" % round((diff/len(DNA1)), 5)


with open('test.txt', 'r') as file:
content = file.read()
DNAs_number, lines, line_number, DNAs = content.count('>'), content.splitlines(), 0, []
for i in range(DNAs_number):
DNA = ''
line_number += 1
while lines[line_number][0] != '>':
DNA += lines[line_number]
line_number += 1
if line_number+1 > len(lines):
break
DNAs.append(DNA)
for i in range(len(DNAs)):
line = ''
for j in range(len(DNAs)):
line += str(p_distance(DNAs[i],DNAs[j]))+ ' '
print(line)

0 comments on commit be64763

Please sign in to comment.