Skip to content

Commit

Permalink
change Seq.ungap("-") to Seq.replace("-","")
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkinsc committed Mar 12, 2024
1 parent 383829a commit 5ab5d6f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions interhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ def load_alignments(self, aligned_files, a_idx=None, b_idx=None):
self.chrMaps[seq1.id] = mapDict

# ungapped strings
#longerSeqLen = max( len(seq1.seq.ungap("-")), len(seq2.seq.ungap("-")) )
#seq1UngappedPadded = str(seq1.seq.ungap("-")).ljust(longerSeqLen, "N")
#seq2UngappedPadded = str(seq2.seq.ungap("-")).ljust(longerSeqLen, "N")
#longerSeqLen = max( len(seq1.seq.replace("-","")), len(seq2.seq.replace("-","")) )
#seq1UngappedPadded = str(seq1.seq.replace("-","")).ljust(longerSeqLen, "N")
#seq2UngappedPadded = str(seq2.seq.replace("-","")).ljust(longerSeqLen, "N")
#mapper = CoordMapper2Seqs(seq1UngappedPadded, seq2UngappedPadded)
#mapDict = self.chrMapsUngapped[seq1.id]
#mapDict[seq2.id] = mapper
Expand Down
6 changes: 3 additions & 3 deletions intrahost.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def merge_to_vcf(
for seq in Bio.SeqIO.parse(inf2, 'fasta'):
if refSeq.id == seq.id:
ref_seq_id_to_alignment_file[seq.id] = alignmentFile
ref_seq_in_alignment_file[seq.id] = seq.seq.ungap('-')
ref_seq_in_alignment_file[seq.id] = seq.seq.replace("-","")

if len(ref_seq_id_to_alignment_file) < len(ref_chrlens):
raise LookupError("Not all reference sequences found in alignments.")
Expand Down Expand Up @@ -627,7 +627,7 @@ def merge_to_vcf(
for seq in Bio.SeqIO.parse(alignFileIn, 'fasta'):
for sampleName in samplesToUse:
if seq.id == sampleName:
samp_to_seqIndex[sampleName] = seq.seq.ungap('-')
samp_to_seqIndex[sampleName] = seq.seq.replace("-","")
break

if not len(samp_to_seqIndex) == len(samplesToUse):
Expand Down Expand Up @@ -739,7 +739,7 @@ def merge_to_vcf(
"for %s at %s:%s-%s.", s, ref_sequence.id, pos, end)
continue

cons = samp_to_seqIndex[s] # .seq.ungap('-')#[ cm.mapChr(ref_sequence.id, s) ]
cons = samp_to_seqIndex[s] # .seq.replace("-","")#[ cm.mapChr(ref_sequence.id, s) ]

allele = str(cons[cons_start - 1:cons_stop]).upper()
if s in samp_offsets:
Expand Down
4 changes: 2 additions & 2 deletions ncbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ def tbl_transfer_prealigned(inputFasta, refFasta, refAnnotTblFiles, outputDir, o
# since alt_chrlens is only used in the case where features would
# extend beyond the genome (for reporting >{seq.len})
alt_chrlens = {}#fasta_chrlens(combined_fasta_filename)
alt_chrlens[seq.id] = len(seq.seq.ungap("-"))
alt_chrlens[matchingRefSeq.id] = len(matchingRefSeq.seq.ungap("-"))
alt_chrlens[seq.id] = len(seq.seq.replace("-",""))
alt_chrlens[matchingRefSeq.id] = len(matchingRefSeq.seq.replace("-",""))

tbl_transfer_common(cmap, ref_tbl, out_tbl, alt_chrlens, oob_clip, ignore_ambig_feature_edge)

Expand Down

0 comments on commit 5ab5d6f

Please sign in to comment.