Skip to content

Commit

Permalink
Shave off another second or so
Browse files Browse the repository at this point in the history
  • Loading branch information
bewt85 committed Feb 5, 2021
1 parent 33c8d03 commit 7854de9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pangolin/scripts/pangolearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def readInAndFormatData(sequencesFile, indiciesToKeep, blockSize=1000):
# possible nucleotide symbols
categories = ['-','A', 'C', 'G', 'T']
columns = [f"{i}_{c}" for i in indiciesToKeep for c in categories]
refRow = {f"{i}_{c}": 1 for i,c in zip(indiciesToKeep, encodeSeq(referenceSeq, indiciesToKeep))}
refRow = [r==c for r in encodeSeq(referenceSeq, indiciesToKeep) for c in categories]

print("loading model " + datetime.now().strftime("%m/%d/%Y, %H:%M:%S"))
loaded_model = joblib.load(args.model_file)
Expand All @@ -129,17 +129,15 @@ def readInAndFormatData(sequencesFile, indiciesToKeep, blockSize=1000):
len(seqList), datetime.now().strftime("%m/%d/%Y, %H:%M:%S")
))

rows = [{f"{i}_{c}": 1 for i,c in zip(indiciesToKeep, row)} for row in seqList]
rows = [[r==c for r in row for c in categories] for row in seqList]
# the reference seq must be added to everry block to make sure that the
# spots in the reference have Ns are in the dataframe to guarentee that
# the correct number of columns is created when get_dummies is called
rows.append(refRow)
idList.append(referenceId)

# create a data from from the seqList
df = pd.DataFrame.from_records(rows, columns=columns)
df.fillna(0, inplace=True)
df = df.astype('uint8')
df = pd.DataFrame(rows, columns=columns).astype('uint8')

predictions = loaded_model.predict_proba(df)

Expand Down

0 comments on commit 7854de9

Please sign in to comment.