@@ -105,8 +105,7 @@ def model_gaps(
105105 >>> res = model_gaps(mol, sequence, "0", "./promod.img") # doctest: +SKIP
106106 """
107107 try :
108- from Bio import pairwise2
109- from Bio .Align import substitution_matrices
108+ from Bio .Align import PairwiseAligner , substitution_matrices
110109 except ImportError :
111110 raise ImportError (
112111 "You need to install the biopython package to use this function. Install it with `conda install biopython`."
@@ -131,18 +130,21 @@ def model_gaps(
131130
132131 molseq = mol .getSequence (dict_key = "segid" )[segid ]
133132
133+ aligner = PairwiseAligner ()
134+ aligner .mode = "global"
134135 # -11 is gap creation penalty. -1 is gap extension penalty. Taken from https://www.arabidopsis.org/Blast/BLASToptions.jsp BLASTP options
135- alignments = pairwise2 .align .globalds (sequence , molseq , blosum62 , - 11.0 , - 1.0 )
136- # elif segment_type == "nucleic":
137- # alignments = pairwise2.align.globalxx(sequence, molseq)
136+ aligner .substitution_matrix = blosum62
137+ aligner .open_gap_score = - 11.0
138+ aligner .extend_gap_score = - 1.0
139+ alignments = aligner .align (sequence , molseq )
138140
139141 print (alignments [0 ])
140142
141143 fastafile = os .path .join (tmpdir , "input.fasta" )
142144 with open (fastafile , "w" ) as f :
143145 # Need to add gaps to sequence
144146 f .write (f">REFERENCE\n { sequence } \n " )
145- f .write (f">{ segid } \n { alignments [0 ]. seqB } " )
147+ f .write (f">{ segid } \n { alignments [0 ][ 1 ] } " )
146148
147149 runpy = os .path .join (tmpdir , "run.py" )
148150 with open (runpy , "w" ) as f :
0 commit comments