Skip to content

Commit

Permalink
bumped requirents and fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyama341 committed Oct 24, 2024
1 parent 70b09f5 commit 29e49fe
Show file tree
Hide file tree
Showing 4 changed files with 351 additions and 227 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# This file is needed for READtheDOCS and GitHub actions- all requirements are installed in the setup.py
pydna==5.2.0 ## TODO There is a new version of pydna 6.0.0 but has induced breaking changes
pydna>=5.2.0 ## TODO There is a new version of pydna 6.0.0 but has induced breaking changes
pandas>=1.3.0
benchlingapi>=2.1.12
numpy>=1.21.0
biopython==1.80 # TODO There is a new version of Biopython 1.82 but has induced breaking changes
biopython>=1.82 # TODO There is a new version of Biopython 1.82 but has induced breaking changes
python-dotenv>=0.20.0
openpyxl>=3.0.9
wheel>=0.37.1
Expand Down
95 changes: 5 additions & 90 deletions teemi/design/cloning.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ def CAS9_cutting(gRNA_record, background_record):
dw.name = "DW" + "_" + gRNA_record.name + "_" + background_record.name

up_feature = Bio.SeqFeature.SeqFeature(
Bio.SeqFeature.FeatureLocation(0, len(up)), type="misc_feature", strand=+1
)
Bio.SeqFeature.FeatureLocation(0, len(up)), type="misc_feature")
up_feature.qualifiers["label"] = up.name
up.features.append(up_feature)

dw_feature = Bio.SeqFeature.SeqFeature(
Bio.SeqFeature.FeatureLocation(0, len(dw)), type="misc_feature", strand=+1
)
Bio.SeqFeature.FeatureLocation(0, len(dw)), type="misc_feature")
dw_feature.qualifiers["label"] = dw.name
dw.features.append(dw_feature)

Expand Down Expand Up @@ -352,7 +350,7 @@ def casembler(
assembly.name = assembly_names[int_no]

assembly_feat = Bio.SeqFeature.SeqFeature(
Bio.SeqFeature.FeatureLocation(0, len(assembly), strand=1),
Bio.SeqFeature.FeatureLocation(0, len(assembly)),
type="misc_feature",
)
assembly_feat.qualifiers["name"] = site_names[int_no]
Expand Down Expand Up @@ -450,9 +448,7 @@ def seq_to_annotation(

feature = Bio.SeqFeature.SeqFeature(
Bio.SeqFeature.FeatureLocation(start_location, end_location),
type=type_name,
strand=strand,
)
type=type_name)

feature.qualifiers["label"] = seq_record_from.id
seq_record_onto.features.append(feature)
Expand Down Expand Up @@ -532,8 +528,7 @@ def add_feature_annotation_to_seqrecord(
None
"""
bio_feature = Bio.SeqFeature.SeqFeature(
Bio.SeqFeature.FeatureLocation(0, len(sequence)), type=type_name, strand=strand
)
Bio.SeqFeature.FeatureLocation(0, len(sequence)), type=type_name)

# label
sequence.features.append(bio_feature)
Expand Down Expand Up @@ -577,83 +572,3 @@ def find_all_occurrences_of_a_sequence(
return len(matches_watson)


# def UPandDW(strain, isite_name, path_to_gRNA_table="../data/raw/gRNAtable.csv"):
# """Finds upstream and downstream sequences based on genome and site name.

# Parameters
# ----------
# strain : str
# name of the strain eg. CENPK113-7d
# (you should specify path to the chromosome)

# isite_name : str
# a string of the site chomosomal site you want to retrieve

# Returns
# -------
# UP_sites : list
# list of pydna.dseqrecord or pydna.amplicon.Amplicon

# DW_sites : list
# list of pydna.dseqrecord or pydna.amplicon.Amplicon

# """

# # load lookup table
# gRNAtable = pd.read_csv(path_to_gRNA_table, index_col="name")

# chromosome_no = gRNAtable.loc[isite_name, "chromosome"]

# # load chromosome
# PathToChromosomeSeq = (
# "../data/raw/" + strain + "/" + str(chromosome_no).zfill(2) + ".fa"
# )
# ChromosomeSeq = Bio.SeqIO.read(PathToChromosomeSeq, "fasta").seq

# # define homology region location with respect to gRNA sequence
# # f_hom is the length of the UP homology
# # e_hom is the length of the DW homology
# # f_dist is distance from end of UP homology to the first base in isite_sequence
# # e_dist is distance from end of the isite_sequence to DW homology
# f_dist = gRNAtable.loc[isite_name, "f_dist"]
# e_dist = gRNAtable.loc[isite_name, "e_dist"]
# f_hom = gRNAtable.loc[isite_name, "f_hom"]
# e_hom = gRNAtable.loc[isite_name, "e_hom"]

# isite_sequence = gRNAtable.loc[isite_name, "sequence"]
# isite_sequence = Bio.Seq.Seq(isite_sequence)

# # Determine gRNA sequence strand
# gRNA_strand = 1
# if ChromosomeSeq.find(isite_sequence) == -1:
# print("not on +1")
# gRNA_strand = -1
# isite_sequence = isite_sequence.reverse_complement()
# if ChromosomeSeq.find(isite_sequence) == -1:
# print("not on -1")
# print("CAN'T FIND THE CUT SITE IN YOUR SEQUENCE")

# # Locate UP and DW
# StartIndex = ChromosomeSeq.find(isite_sequence)
# EndIndex = StartIndex

# UPseq = ChromosomeSeq[StartIndex + f_dist - f_hom : StartIndex + f_dist]
# DWseq = ChromosomeSeq[EndIndex + e_dist : EndIndex + e_dist + e_hom]

# UPrec = Bio.SeqRecord.SeqRecord(UPseq, name=isite_name + "UP")
# DWrec = Bio.SeqRecord.SeqRecord(DWseq, name=isite_name + "DW")

# # Annotate
# UP_feature = Bio.SeqFeature.SeqFeature(
# Bio.SeqFeature.FeatureLocation(0, len(UPseq)), type="misc_feature", strand=+1
# )
# UP_feature.qualifiers["label"] = UPrec.name
# UPrec.features.append(UP_feature)

# DW_feature = Bio.SeqFeature.SeqFeature(
# Bio.SeqFeature.FeatureLocation(0, len(DWseq)), type="misc_feature", strand=+1
# )
# DW_feature.qualifiers["label"] = DWrec.name
# DWrec.features.append(DW_feature)

# return ([UPrec], [DWrec])
16 changes: 10 additions & 6 deletions tests/test_cloning.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ def test_seq_to_annotation():
# The actual test
seq_to_annotation(test_sequence, test_plasmid, 'AMPLICON2')

assert test_plasmid.features[-1].type == 'AMPLICON2'
assert test_plasmid.features[-1].location.start.position == 0
assert test_plasmid.features[-1].location.end.position == 100
## Assertions to verify the annotation
assert test_plasmid.features[-1].type == 'AMPLICON2', "Feature type should be 'AMPLICON2'"

# Access the start and end positions correctly
assert int(test_plasmid.features[-1].location.start) == 0, "Feature start position should be 0"
assert int(test_plasmid.features[-1].location.end) == 100, "Feature end position should be 100"


def test_casembler():
Expand Down Expand Up @@ -205,11 +208,12 @@ def test_crispr_db_break_location():

def test_add_feature_annotation_to_seqrecord():
test_plasmid = SeqIO.read('../teemi/tests/files_for_testing/MIA-HA-1.gb', 'gb')
add_feature_annotation_to_seqrecord(test_plasmid,label=f'This a test', strand = 1)
add_feature_annotation_to_seqrecord(test_plasmid,label=f'This a test')

assert test_plasmid.features[0].qualifiers['label'] == 'This a test'
assert test_plasmid.features[-1].location.start.position == 0
assert test_plasmid.features[-1].location.end.position == len(test_plasmid)
# Directly use the ExactPosition as an integer
assert int(test_plasmid.features[-1].location.start) == 0
assert int(test_plasmid.features[-1].location.end) == len(test_plasmid)



Expand Down
Loading

0 comments on commit 29e49fe

Please sign in to comment.