@@ -283,15 +283,18 @@ def _parse_maverick(self):
283283 """
284284
285285 # Explanation of data import:
286- # 1. Import data using genfromtxt numpy method, specifiying the
287- # delimiter and skiping the first header line
288- # 2. Remove the first three columns from the array with .T[3:].
289- # However, this messes the shape of the structure array, so....
290- # 3. We transpose the array so that each row is a taxon and
291- # the columns represent the assignment probabilities for each K
292- mavarray = np .genfromtxt (self .file_path , delimiter = "," ,
293- skip_header = 1 )
294- self .qvals = mavarray .T [3 :].T
286+ # 1. Figure out which columns we need to parse by reading the file
287+ # header
288+ # 2. Import data using genfromtxt numpy method, specifiying the
289+ # delimiter, skiping the header line and using only the "demes"
290+ # columns
291+ mavfile = open (self .file_path , "r" )
292+ header = mavfile .readline ().rstrip ()
293+ mavfile .close ()
294+ demes = [i for i , j in enumerate (header .split ("," )) if "deme" in j ]
295+
296+ self .qvals = np .genfromtxt (self .file_path , delimiter = "," ,
297+ skip_header = 1 , usecols = demes )
295298
296299 if self .get_indv :
297300 self .indv = list (np .genfromtxt (self .file_path , delimiter = "," ,
0 commit comments