Skip to content

Commit

Permalink
Hopefully final.
Browse files Browse the repository at this point in the history
  • Loading branch information
anicksaha committed Nov 7, 2019
1 parent 88f946c commit 159ab15
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def bootstrap(root, ids, sequences):
bootstrap_sequences[id] = bootstrap_seq

# Neisaitou and Distance Matrix for the new sequences
distMatrix = utils.get_distMatrix(ids, bootstrap_sequences)
distMatrix = utils.get_distance_matrix(ids, bootstrap_sequences)
seqCounter = 120
root = neighbour_joining.nei_saitou(ids, distMatrix, seqCounter)
# get the dictionary of partitions and ids under those partitions
Expand Down
4 changes: 2 additions & 2 deletions edges.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
63 64 0.00376827912568
64 69 0.0114938796716
69 70 0.00240415262502
70 42 0.095761467563
70 19 0.0913179402432
70 42 0.095761467563
69 6 0.068928283445
64 74 0.0138257703957
74 43 0.0701951689325
Expand Down Expand Up @@ -85,8 +85,8 @@
83 91 0.013850279425
91 102 0.00423269087876
102 104 0.00461971797755
104 13 0.0802724654919
104 51 0.0825808319509
104 13 0.0802724654919
102 105 0.00656803437777
105 110 0.0177473177689
110 50 0.0824905753015
Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ def main(filename):
ids, sequences = utils.read_fasta_file(filename)

# Then generate the distance matrix
distance_matrix = utils.get_distMatrix(ids, sequences)
distance_matrix = utils.get_distance_matrix(ids, sequences)

# write the distances.txt file (distance matrix)
utils.write_distMatrix(ids, distance_matrix)
utils.write_distance_matrix(ids, distance_matrix)

# This is used to number the sequences/nodes in the tree to be constructed
# This is used to number nodes in the tree to be constructed
sequence_counter = 120
# Run the nei saitu algorithm. Returns the root of the tree
root = neighbour_joining.nei_saitou(ids, distance_matrix, sequence_counter)
Expand Down
Binary file modified tree.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion tree.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(((4439229:0.0994636314408,(164216:0.0805450227767,146154:0.0648116394037):0.0142644977651):0.00735813002246,((720729:0.097762461851,(((((100149:0.0486748871823,(4468812:0.0261929524043,166838:0.0343723235042):0.0135727575014):0.0312959330949,348167:0.0893299080895):0.0107871348319,(286686:0.0867460556338,((779409:0.04678825286,593544:0.060210401245):0.00697756765851,4387271:0.0431570218435):0.0165513871656):0.00338682209946):0.0117075956228,(11136:0.104185713798,(5364:0.0459632162084,(3148512:0.0387720577239,106543:0.0419816434874):0.0112373221496):0.024851971263):0.00389111736513):0.00387210426656,(((1920715:0.120428860031,(260976:0.0822133814411,646961:0.0759292834311):0.0141606419883):0.0116483249952,((((4378332:0.0506567246683,523025:0.0846057248606):0.0147056847708,(511006:0.0515193738372,(((273179:0.0226913456411,188674:0.020377295005):0.000565372968216,319214:0.0219783686199):0.0109189939435,197222:0.0380379374159):0.0254489976298):0.0132847257272):0.00561348628869,(806723:0.0722060713208,(1009440:0.0708603722105,((954340:0.0772832314566,947627:0.0727840632945):0.00484880367808,(4164932:0.0605401041029,(565897:0.0476464546292,144260:0.0337801940922):0.0454491287369):0.00415186926943):0.00135530746646):0.00572966219195):0.0100726310145):0.00375090334222,4397763:0.0781236103481):0.0106890635478):0.00388775124005,((((664158:0.0802724654919,822879:0.0825808319509):0.00461971797755,((3906666:0.0824905753015,(816087:0.0812659224188,4448694:0.0762037949433):0.0255175000687):0.0177473177689,(4431405:0.0543373959424,809189:0.0614095757938):0.0302843107641):0.00656803437777):0.00423269087876,((2034243:0.094206517777,208595:0.0686467796658):0.00510333767336,996519:0.0891093137398):0.025745017735):0.013850279425,((152801:0.115587289276,3855581:0.124654971827):0.0215198171439,4345542:0.132248688913):0.188580743455):0.0120725313848):0.0120473718793):0.00536520381635):0.00336721222622,((2263183:0.0648454483874,((586332:0.0726342497929,1136782:0.103677997852):0.00763606407822,2963287:0.0704258470927):0.0074964089477):0.00238916628989,(555079:0.0352536797343,553272:0.0313681237651):0.0385765133871):0.0120786458936):0.00753624506626):0.000959080610108);
(((4439229:0.0994636314408,(164216:0.0805450227767,146154:0.0648116394037):0.0142644977651):0.00735813002246,((720729:0.097762461851,(((((100149:0.0486748871823,(4468812:0.0261929524043,166838:0.0343723235042):0.0135727575014):0.0312959330949,348167:0.0893299080895):0.0107871348319,(286686:0.0867460556338,((779409:0.04678825286,593544:0.060210401245):0.00697756765851,4387271:0.0431570218435):0.0165513871656):0.00338682209946):0.0117075956228,(11136:0.104185713798,(5364:0.0459632162084,(3148512:0.0387720577239,106543:0.0419816434874):0.0112373221496):0.024851971263):0.00389111736513):0.00387210426656,(((1920715:0.120428860031,(260976:0.0822133814411,646961:0.0759292834311):0.0141606419883):0.0116483249952,((((4378332:0.0506567246683,523025:0.0846057248606):0.0147056847708,(511006:0.0515193738372,(((273179:0.0226913456411,188674:0.020377295005):0.000565372968216,319214:0.0219783686199):0.0109189939435,197222:0.0380379374159):0.0254489976298):0.0132847257272):0.00561348628869,(806723:0.0722060713208,(1009440:0.0708603722105,((954340:0.0772832314566,947627:0.0727840632945):0.00484880367808,(4164932:0.0605401041029,(565897:0.0476464546292,144260:0.0337801940922):0.0454491287369):0.00415186926943):0.00135530746646):0.00572966219195):0.0100726310145):0.00375090334222,4397763:0.0781236103481):0.0106890635478):0.00388775124005,((((822879:0.0825808319509,664158:0.0802724654919):0.00461971797755,((3906666:0.0824905753015,(816087:0.0812659224188,4448694:0.0762037949433):0.0255175000687):0.0177473177689,(4431405:0.0543373959424,809189:0.0614095757938):0.0302843107641):0.00656803437777):0.00423269087876,((2034243:0.094206517777,208595:0.0686467796658):0.00510333767336,996519:0.0891093137398):0.025745017735):0.013850279425,((152801:0.115587289276,3855581:0.124654971827):0.0215198171439,4345542:0.132248688913):0.188580743455):0.0120725313848):0.0120473718793):0.00536520381635):0.00336721222622,((2263183:0.0648454483874,((586332:0.0726342497929,1136782:0.103677997852):0.00763606407822,2963287:0.0704258470927):0.0074964089477):0.00238916628989,(555079:0.0352536797343,553272:0.0313681237651):0.0385765133871):0.0120786458936):0.00753624506626):0.000959080610108);
4 changes: 2 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_distance(seq1,seq2):


# Fucntion to get the overall distance matrix for all the sequences.
def get_distMatrix(ids, sequences):
def get_distance_matrix(ids, sequences):
total = len(ids)
matrix = [[0] * total for _ in range(total)]
for i, id1 in enumerate(ids):
Expand All @@ -36,7 +36,7 @@ def get_distMatrix(ids, sequences):


# writes the distance matrix to a file
def write_distMatrix(ids, matrix):
def write_distance_matrix(ids, matrix):
num_ids = len(ids)
with open('genetic_distances.txt', 'w') as f:
# First append the row of ids.
Expand Down

0 comments on commit 159ab15

Please sign in to comment.