@@ -550,15 +550,20 @@ def compute_laa_field(genotypes):
550
550
551
551
552
552
def compute_lad_field (ad , laa ):
553
- lad = np .full ((ad .shape [0 ], 2 ), - 2 , dtype = ad .dtype )
554
- ref_ref = np .where ((laa [:, 0 ] == - 2 ) & (laa [:, 1 ] == - 2 ))[0 ]
555
- lad [ref_ref , 0 ] = ad [ref_ref , 0 ]
556
- ref_alt = np .where ((laa [:, 0 ] != - 2 ) & (laa [:, 1 ] == - 2 ))[0 ]
557
- lad [ref_alt , 0 ] = ad [ref_alt , 0 ]
558
- lad [ref_alt , 1 ] = ad [ref_alt , laa [ref_alt , 0 ]]
559
- alt_alt = np .where ((laa [:, 0 ] != - 2 ) & (laa [:, 1 ] != - 2 ))[0 ]
560
- lad [alt_alt , 0 ] = ad [alt_alt , laa [alt_alt , 0 ]]
561
- lad [alt_alt , 1 ] = ad [alt_alt , laa [alt_alt , 1 ]]
553
+ try :
554
+ lad = np .full ((ad .shape [0 ], 2 ), - 2 , dtype = ad .dtype )
555
+ ref_ref = np .where ((laa [:, 0 ] == - 2 ) & (laa [:, 1 ] == - 2 ))[0 ]
556
+ lad [ref_ref , 0 ] = ad [ref_ref , 0 ]
557
+ ref_alt = np .where ((laa [:, 0 ] != - 2 ) & (laa [:, 1 ] == - 2 ))[0 ]
558
+ lad [ref_alt , 0 ] = ad [ref_alt , 0 ]
559
+ lad [ref_alt , 1 ] = ad [ref_alt , laa [ref_alt , 0 ]]
560
+ alt_alt = np .where ((laa [:, 0 ] != - 2 ) & (laa [:, 1 ] != - 2 ))[0 ]
561
+ lad [alt_alt , 0 ] = ad [alt_alt , laa [alt_alt , 0 ]]
562
+ lad [alt_alt , 1 ] = ad [alt_alt , laa [alt_alt , 1 ]]
563
+ except Exception as e :
564
+ print ("ad = " , ad )
565
+ print ("laa = " , laa )
566
+ raise e
562
567
return lad
563
568
564
569
@@ -875,21 +880,22 @@ def encode_local_alleles_partition(self, partition_index):
875
880
call_AD_source = self .icf .fields ["FORMAT/AD" ].iter_values (
876
881
partition .start , partition .stop
877
882
)
878
-
879
883
gt_array = zarr .open_array (
880
884
store = self .wip_partition_array_path (partition_index , "call_genotype" ),
881
885
mode = "r" ,
882
886
)
883
- for chunk_index in range (gt_array .cdata_shape [0 ]):
884
- for genotypes in gt_array .blocks [chunk_index ]:
885
- laa = compute_laa_field (genotypes )
886
- j = call_LAA .next_buffer_row ()
887
- call_LAA .buff [j ] = laa
888
-
889
- ad = next (call_AD_source )
890
- j = call_LAD .next_buffer_row ()
891
- lad = compute_lad_field (ad , laa )
892
- call_LAD .buff [j ] = lad
887
+ for genotypes in core .first_dim_slice_iter (
888
+ gt_array , partition .start , partition .stop
889
+ ):
890
+ laa = compute_laa_field (genotypes )
891
+ j = call_LAA .next_buffer_row ()
892
+ call_LAA .buff [j ] = laa
893
+
894
+ ad = next (call_AD_source )
895
+ k = call_LAD .next_buffer_row ()
896
+ assert j == k
897
+ lad = compute_lad_field (ad , laa )
898
+ call_LAD .buff [j ] = lad
893
899
894
900
call_LAA .flush ()
895
901
self .finalise_partition_array (partition_index , "call_LAA" )
0 commit comments