@@ -557,7 +557,7 @@ pub struct GenotypeInfo {
557557    pub  amq :  Option < i32 > , 
558558    /// Copy number. 
559559     #[ serde( default ,  skip_serializing_if = "Option::is_none" ) ]  
560-     pub  cn :  Option < i32 > , 
560+     pub  cn :  Option < f32 > , 
561561    /// Average normalized coverage. 
562562     #[ serde( default ,  skip_serializing_if = "Option::is_none" ) ]  
563563    pub  anc :  Option < f32 > , 
@@ -887,7 +887,7 @@ impl AsyncAnnotatedVariantWriter for VarFishStrucvarTsvWriter {
887887                        entry. src  = Some ( * src) ; 
888888                    } 
889889                    // amq 
890-                     ( "CN" ,  Some ( sample:: Value :: Integer ( cn) ) )  => { 
890+                     ( "CN" ,  Some ( sample:: Value :: Float ( cn) ) )  => { 
891891                        entry. cn  = Some ( * cn) ; 
892892                    } 
893893                    // anc 
@@ -1403,7 +1403,7 @@ impl TryInto<VcfRecord> for VarFishStrucvarTsvRecord {
14031403                    . amq
14041404                    . as_ref( ) 
14051405                    . map( |amq| sample:: Value :: Integer ( * amq) ) , 
1406-                 genotype. cn. as_ref( ) . map( |cn| sample:: Value :: Integer ( * cn) ) , 
1406+                 genotype. cn. as_ref( ) . map( |cn| sample:: Value :: Float ( * cn) ) , 
14071407                genotype. anc. as_ref( ) . map( |anc| sample:: Value :: Float ( * anc) ) , 
14081408                genotype. pc. as_ref( ) . map( |pc| sample:: Value :: Integer ( * pc) ) , 
14091409            ] ) ; 
@@ -2102,9 +2102,12 @@ mod conv {
21022102                            process_gt ( & mut  entries,  sample_no,  & gt,  pedigree,  tsv_record) ; 
21032103                        } 
21042104                        // Obtain `GenotypeInfo::cn` from `FORMAT/CN`. 
2105-                         ( "CN" ,  Some ( sample:: Value :: Integer ( cn) ) )  => { 
2105+                         ( "CN" ,  Some ( sample:: Value :: Float ( cn) ) )  => { 
21062106                            entries[ sample_no] . cn  = Some ( * cn) ; 
21072107                        } 
2108+                         ( "CN" ,  Some ( sample:: Value :: Integer ( cn) ) )  => { 
2109+                             entries[ sample_no] . cn  = Some ( * cn as  f32 ) ; 
2110+                         } 
21082111                        // Obtain `GenotypeInfo::gq` from `FORMAT/GQ`. 
21092112                        ( "GQ" ,  Some ( sample:: Value :: Integer ( gq) ) )  => { 
21102113                            entries[ sample_no] . gq  = Some ( * gq) ; 
@@ -2287,9 +2290,12 @@ mod conv {
22872290                            entries[ sample_no] . pev  = Some ( * pe) ; 
22882291                        } 
22892292                        // Obtain `GenotypeInfo::cn` from `FORMAT/CN`. 
2290-                         ( "CN" ,  Some ( sample:: Value :: Integer ( cn) ) )  => { 
2293+                         ( "CN" ,  Some ( sample:: Value :: Float ( cn) ) )  => { 
22912294                            entries[ sample_no] . cn  = Some ( * cn) ; 
22922295                        } 
2296+                         ( "CN" ,  Some ( sample:: Value :: Integer ( cn) ) )  => { 
2297+                             entries[ sample_no] . cn  = Some ( * cn as  f32 ) ; 
2298+                         } 
22932299                        // Obtain `GenotypeInfo::pc` from `FORMAT/BC`. 
22942300                        ( "BC" ,  Some ( sample:: Value :: Integer ( bc) ) )  => { 
22952301                            entries[ sample_no] . pc  = Some ( * bc) ; 
@@ -2402,9 +2408,12 @@ mod conv {
24022408                            process_gt ( & mut  entries,  sample_no,  & gt,  pedigree,  tsv_record) ; 
24032409                        } 
24042410                        // Obtain `GenotypeInfo::cn` from `FORMAT/CN`. 
2405-                         ( "CN" ,  Some ( sample:: Value :: Integer ( cn) ) )  => { 
2411+                         ( "CN" ,  Some ( sample:: Value :: Float ( cn) ) )  => { 
24062412                            entries[ sample_no] . cn  = Some ( * cn) ; 
24072413                        } 
2414+                         ( "CN" ,  Some ( sample:: Value :: Integer ( cn) ) )  => { 
2415+                             entries[ sample_no] . cn  = Some ( * cn as  f32 ) ; 
2416+                         } 
24082417                        // Obtain `GenotypeInfo::pc` from `FORMAT/NP`. 
24092418                        ( "NP" ,  Some ( sample:: Value :: Integer ( np) ) )  => { 
24102419                            entries[ sample_no] . pc  = Some ( * np) ; 
@@ -2780,15 +2789,24 @@ mod conv {
27802789                    . unwrap_or_else ( || panic ! ( "sample must be in pedigree: {:?}" ,  & entry. name) ) 
27812790                    . sex ; 
27822791                let  expected_cn = match  ( sex,  is_chr_x,  is_chr_y)  { 
2783-                     ( _,  false ,  false )  => Some ( 2 ) , 
2784-                     ( Sex :: Male ,  false ,  true )  | ( Sex :: Male ,  true ,  false )  => Some ( 1 ) , 
2785-                     ( Sex :: Female ,  true ,  false )  => Some ( 2 ) , 
2792+                     ( _,  false ,  false )  => Some ( 2.  ) , 
2793+                     ( Sex :: Male ,  false ,  true )  | ( Sex :: Male ,  true ,  false )  => Some ( 1.  ) , 
2794+                     ( Sex :: Female ,  true ,  false )  => Some ( 2.  ) , 
27862795                    // do not count, sex missing or conflicting chromosome 
27872796                    _ => None , 
27882797                } ; 
27892798                if  let  ( Some ( cn) ,  Some ( expected_cn) )  = ( entry. cn ,  expected_cn)  { 
27902799                    let  delta = ( cn - expected_cn) . abs ( ) ; 
2791-                     if  expected_cn == 1  { 
2800+                     if  delta. round ( )  != delta { 
2801+                         tracing:: warn!( 
2802+                             "Fractional CN value: {} and expected {} for sample {}, rounding." , 
2803+                             cn, 
2804+                             expected_cn, 
2805+                             entry. name, 
2806+                         ) ; 
2807+                     } 
2808+                     let  delta = delta. round ( )  as  i32 ; 
2809+                     if  expected_cn == 1.  { 
27922810                        tsv_record. num_hemi_alt  += delta; 
27932811                    }  else  if  delta == 0  { 
27942812                        tsv_record. num_hom_ref  += 1 ; 
@@ -3988,7 +4006,7 @@ mod test {
39884006                            src:  Some ( 143 ) , 
39894007                            srv:  Some ( 43 ) , 
39904008                            amq:  Some ( 99 ) , 
3991-                             cn:  Some ( 1 ) , 
4009+                             cn:  Some ( 1.  ) , 
39924010                            anc:  Some ( 0.5 ) , 
39934011                            pc:  Some ( 10 ) , 
39944012                        } , 
@@ -4002,7 +4020,7 @@ mod test {
40024020                            src:  Some ( 44 ) , 
40034021                            srv:  Some ( 0 ) , 
40044022                            amq:  Some ( 98 ) , 
4005-                             cn:  Some ( 2 ) , 
4023+                             cn:  Some ( 2.  ) , 
40064024                            anc:  Some ( 1.0 ) , 
40074025                            pc:  Some ( 10 ) , 
40084026                        } , 
@@ -4016,7 +4034,7 @@ mod test {
40164034                            src:  Some ( 33 ) , 
40174035                            srv:  Some ( 0 ) , 
40184036                            amq:  Some ( 97 ) , 
4019-                             cn:  Some ( 2 ) , 
4037+                             cn:  Some ( 2.  ) , 
40204038                            anc:  Some ( 1.0 ) , 
40214039                            pc:  Some ( 10 ) , 
40224040                        } , 
@@ -4064,7 +4082,7 @@ mod test {
40644082                            src:  Some ( 143 ) , 
40654083                            srv:  Some ( 43 ) , 
40664084                            amq:  Some ( 99 ) , 
4067-                             cn:  Some ( 1 ) , 
4085+                             cn:  Some ( 1.  ) , 
40684086                            anc:  Some ( 0.5 ) , 
40694087                            pc:  Some ( 10 ) , 
40704088                        } , 
@@ -4078,7 +4096,7 @@ mod test {
40784096                            src:  Some ( 143 ) , 
40794097                            srv:  Some ( 43 ) , 
40804098                            amq:  Some ( 99 ) , 
4081-                             cn:  Some ( 1 ) , 
4099+                             cn:  Some ( 1.  ) , 
40824100                            anc:  Some ( 0.5 ) , 
40834101                            pc:  Some ( 10 ) , 
40844102                        } , 
@@ -4092,7 +4110,7 @@ mod test {
40924110                            src:  Some ( 143 ) , 
40934111                            srv:  Some ( 43 ) , 
40944112                            amq:  Some ( 99 ) , 
4095-                             cn:  Some ( 1 ) , 
4113+                             cn:  Some ( 1.  ) , 
40964114                            anc:  Some ( 0.5 ) , 
40974115                            pc:  Some ( 10 ) , 
40984116                        } , 
0 commit comments