@@ -174,24 +174,30 @@ def polarizeSnps(unmasked, positions, refAlleles, altAlleles, ancArm):
174174
175175 mapping = []
176176 for i in range (len (ancArm )):
177- if ancArm [i ] in "ACGT " :
177+ if ancArm [i ] in "ACGT01 " :
178178 if i + 1 in isSnp :
179179 ref , alt = refAlleles [isSnp [i + 1 ]], altAlleles [isSnp [i + 1 ]]
180- if ancArm [i ] == ref :
181- mapping .append ([0 , 1 ]) # no swap
182- elif ancArm [i ] == alt :
183- mapping .append ([1 , 0 ]) # swap
180+ if ancArm [i ] in "ACGT" :
181+ if ancArm [i ] == ref :
182+ mapping .append ([0 , 1 ]) # no swap
183+ elif ancArm [i ] == alt :
184+ mapping .append ([1 , 0 ]) # swap
185+ else :
186+ mapping .append ([0 , 1 ]) # no swap -- failed to polarize
187+ unmasked [i ] = False
184188 else :
185- mapping .append ([0 , 1 ]) # no swap -- failed to polarize
186- unmasked [i ] = False
189+ if ancArm [i ] == '0' :
190+ mapping .append ([0 , 1 ]) # no swap - '0' represents ancestral
191+ else : # ancArm[i] == '1'
192+ mapping .append ([1 , 0 ]) # swap - '1' represents derived
187193 elif ancArm [i ] == "N" :
188194 unmasked [i ] = False
189195 if i + 1 in isSnp :
190196 mapping .append ([0 , 1 ]) # no swap -- failed to polarize
191197 else :
192198 sys .exit (
193199 "Found a character in ancestral chromosome "
194- "that is not 'A', 'C', 'G', 'T' or 'N' (all upper case)!\n "
200+ "that is not 'A', 'C', 'G', 'T', '0', '1' or 'N' (all upper case)!\n "
195201 )
196202 assert len (mapping ) == len (positions )
197203 return mapping , unmasked
0 commit comments