Last active
September 23, 2020 12:59
-
-
Save soh-i/87f005a425a0d04c4cf308ac52048be3 to your computer and use it in GitHub Desktop.
Fast Local Alignment in Julia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module main | |
using BioSequences | |
using BioAlignments | |
using BenchmarkTools | |
struct AlignmentResults | |
align::BioAlignments.PairwiseAlignmentResult | |
name::String | |
end | |
function generate_fasta_db(fasta_path::String)::Dict{String, BioSequences.BioSequence} | |
db = Dict{String, BioSequences.BioSequence}() | |
reader = BioSequences.FASTA.Reader(open(fasta_path, "r")) | |
for record in reader | |
sequence = BioSequences.FASTA.sequence(record) | |
id::String = BioSequences.FASTA.identifier(record) | |
db[id] = sequence | |
end | |
close(reader) | |
return db | |
end | |
const PS1 = BioSequences.dna"TAACTTACGGAGTCGCTCTACG" | |
function sw_alignments() | |
fasta = "sampled_50000.fasta" | |
fasta_db = generate_fasta_db(fasta) | |
problem = BioAlignments.LocalAlignment() #smith-waterman local alignment | |
scoremodel = BioAlignments.AffineGapScoreModel(match=5, mismatch=-4, gap_open=-4, gap_extend=-1) | |
global i = 1 | |
for (name, seq) in fasta_db | |
align = pairalign(problem, seq, PS1, scoremodel) | |
i += 1 | |
end | |
@show("Processed $i alignments in total") | |
end | |
for i in 1:10 | |
@time main.sw_alignments() | |
end | |
end |
Author
soh-i
commented
Sep 23, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment