Skip to content

Commit

Permalink
updated rest of files to pyfaidx. fixed int overflow error
Browse files Browse the repository at this point in the history
  • Loading branch information
fairliereese committed Feb 23, 2023
1 parent ccd4b30 commit 2ce2ced
Show file tree
Hide file tree
Showing 26 changed files with 81 additions and 68 deletions.
18 changes: 10 additions & 8 deletions TranscriptClean.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ def transcript_init(transcript_line, genome, sjAnnot):
if logInfo.Mapping != "primary":
return None, logInfo

try:
transcript = Transcript(sam_fields, genome, sjAnnot)
# try:
transcript = Transcript(sam_fields, genome, sjAnnot)

except Exception as e:
warnings.warn("Problem parsing transcript with ID '" +
logInfo.TranscriptID + "'")
print(e)
return None, logInfo
# except Exception as e:
# warnings.warn("Problem parsing transcript with ID '" +
# logInfo.TranscriptID + "'")
# print(e)
# return None, logInfo

return transcript, logInfo

Expand Down Expand Up @@ -1365,7 +1365,9 @@ def combinedJunctionDist(dist_0, dist_1):
"""
# If dist_0 and dist_1 have different signs, the combined distance is
# the sum of their absolute values
if dist_0*dist_1 <= 0:
# https://stackoverflow.com/questions/66882/simplest-way-to-check-if-two-integers-have-same-sign
if ((dist_0<0)!=(dist_1<0)):
# if dist_0*dist_1 <= 0:
combined_dist = abs(dist_0) + abs(dist_1)
else:
combined_dist = abs(abs(dist_0) - abs(dist_1))
Expand Down
16 changes: 11 additions & 5 deletions intronBound.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, transcriptID, jnNumber, ibNumber, chrom, pos, strand):
self.strand = strand

def getBED(self):
""" Format the intron boundary with 0-based start and end.
""" Format the intron boundary with 0-based start and end.
If mode == "start", we return a bed for the start position."""

bedstr = "\t".join([self.chrom, str(self.pos - 1), str(self.pos),
Expand All @@ -31,9 +31,15 @@ def getSpliceMotif(self, genome):
intron (first two if bound == 0 and last two if bound == 1) """

if self.bound == 0:
motif = genome.sequence(
{'chr': self.chrom, 'start': self.pos, 'stop': self.pos + 1}, one_based=True)
# motif = genome.sequence(
# {'chr': self.chrom, 'start': self.pos, 'stop': self.pos + 1}, one_based=True)
motif = genome.get_seq(self.chrom,
self.pos,
self.pos+1).seq
else:
motif = genome.sequence(
{'chr': self.chrom, 'start': self.pos - 1, 'stop': self.pos}, one_based=True)
# motif = genome.sequence(
# {'chr': self.chrom, 'start': self.pos - 1, 'stop': self.pos}, one_based=True)
motif = genome.get_seq(self.chrom,
self.pos-1,
self.pos).seq
return motif
11 changes: 5 additions & 6 deletions testing_suite/test_all_jns_annotated.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand All @@ -11,7 +11,7 @@ class TestAllSJsAnnot(object):
def test_no_jns(self):
""" Return transcript.allJnsAnnotated = True for a transcript without
junctions"""

sam = "input_files/sams/perfectReferenceMatch_noIntrons.sam"
genome = Fasta("input_files/hg38_chr1.fa")

Expand Down Expand Up @@ -56,7 +56,7 @@ def test_two_annotated_SJs_without_ref(self):
assert transcript.isCanonical == True

def test_noncanonical(self):
""" Transcript should be noncanonical and un-annotated prior to
""" Transcript should be noncanonical and un-annotated prior to
correction, but be canonical and annotated afterwards """

sam = "input_files/sams/deletion_insertion_mismatch_nc.sam"
Expand All @@ -70,15 +70,14 @@ def test_noncanonical(self):

with open(sam, 'r') as f:
sam_line = f.readline().strip()
transcript, logInfo = TC.transcript_init(sam_line, refs.genome,
transcript, logInfo = TC.transcript_init(sam_line, refs.genome,
refs.sjAnnot)

assert transcript.allJnsAnnotated == False
assert transcript.isCanonical == False

# Now correct the junction and retest
upd_transcript, TE = TC.cleanNoncanonical(transcript, refs, 5, logInfo)
upd_transcript, TE = TC.cleanNoncanonical(transcript, refs, 5, logInfo)

assert upd_transcript.allJnsAnnotated == True
assert upd_transcript.isCanonical == True

2 changes: 1 addition & 1 deletion testing_suite/test_attempt_jn_correction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_canonOnly_mode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
import os
import subprocess
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_combined_jn_dist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import TranscriptClean as TC
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_compare_seq_cigar_lengths.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_compute_MD_NM.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_compute_jI_jM.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_correct_deletions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_correct_insertions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_correct_mismatches.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_example_transcripts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
import os
import subprocess
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_example_varDM_monoexon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
import os
import subprocess
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_fetch_donor_or_acceptor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import spliceJunction as sj
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_find_closest_annotated_SJ.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import spliceJunction as sj
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_find_closest_annotated_bound.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import intronBound as ib
import spliceJunction as sj
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta


@pytest.mark.unit
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_find_ncsj.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_fix_one_side_of_junction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_full_dryrun.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
import os
import subprocess
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_high_level_ncsj_correction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import os
import sys
sys.path.append("..")
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_init_transcript_object.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import TranscriptClean as TC
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_print_fasta_seq.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as ts
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_rmTmp_option.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
import os
import subprocess
Expand Down
2 changes: 1 addition & 1 deletion testing_suite/test_update_post_ncsj_correction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pyfasta import Fasta
from pyfaidx import Fasta
import sys
sys.path.append("..")
import transcript as t2
Expand Down
Loading

0 comments on commit 2ce2ced

Please sign in to comment.