@@ -70,14 +70,16 @@ pub fn read_features<R>(
70
70
where
71
71
R : BufRead ,
72
72
{
73
+ use noodles:: gff:: lazy:: { record:: attributes:: field:: Value , Line } ;
74
+
73
75
let mut features: HashMap < String , Vec < Feature > > = HashMap :: new ( ) ;
74
76
75
77
info ! ( "reading features" ) ;
76
78
77
- let mut line = noodles :: gff :: lazy :: Line :: default ( ) ;
79
+ let mut line = Line :: default ( ) ;
78
80
79
81
while reader. read_lazy_line ( & mut line) ? != 0 {
80
- let noodles :: gff :: lazy :: Line :: Record ( ref record) = line else {
82
+ let Line :: Record ( ref record) = line else {
81
83
continue ;
82
84
} ;
83
85
@@ -86,17 +88,21 @@ where
86
88
}
87
89
88
90
let reference_sequence_name = record. reference_sequence_name ( ) ;
89
- let start = record. start ( ) . try_into ( ) ?;
90
- let end = record. end ( ) . try_into ( ) ?;
91
- let strand = record. strand ( ) . try_into ( ) ?;
91
+ let start = record. start ( ) ?;
92
+ let end = record. end ( ) ?;
93
+ let strand = record. strand ( ) ?;
92
94
93
95
let feature = Feature :: new ( reference_sequence_name. into ( ) , start, end, strand) ;
94
96
95
97
let attributes = record. attributes ( ) ;
96
98
let id = attributes
97
99
. get ( feature_id)
98
100
. ok_or_else ( || ReadFeaturesError :: MissingAttribute ( feature_id. into ( ) ) ) ?
99
- . map_err ( |_| ReadFeaturesError :: InvalidAttribute ( feature_id. into ( ) ) ) ?;
101
+ . map_err ( |_| ReadFeaturesError :: InvalidAttribute ( feature_id. into ( ) ) )
102
+ . and_then ( |value| match value {
103
+ Value :: String ( s) => Ok ( s) ,
104
+ Value :: Array ( _) => Err ( ReadFeaturesError :: InvalidAttribute ( feature_id. into ( ) ) ) ,
105
+ } ) ?;
100
106
101
107
let list = features. entry ( id. into ( ) ) . or_default ( ) ;
102
108
0 commit comments