from pydna.parsers import parse

f,r, _, _ = parse('''

>807_pYPK0_hygfwd2
tctgacgctcagtggaacgaaaactcacgttaagggattttggtcatgagCACATACGATTTAGGTGACAC

>806_pYPK0_hygrev2
atagtccgtggaattaattctcatctttgacagcttatcatcgataagctCGACTCACTATAGGGAGAC

>678_pYPK0_hygfwd: (77-mer)
ctcacgttaagggattttggtcatgagCACATACGATTTAGGTGACACTATAGAAC

>666_pYPK0_hygrev (70-mer)
catctttgacagcttatcatcgataagctCGACTCACTATAGGGAGACC
''')

"""
Explanation: The pMEC1049 xylose pathway vector
The pMEC1049 xylose pathway vector was used in Romani et al. 2014 to create xylose fermenting industrial yeast strains. The pMEC1049 is essentially a version of the four gene xylose pathway pMEC1135 but with the dominant hygromycin selectable marker hphMX4 instead of the URA3 marker. This makes it suitable for yeast strains without auxotrophical markers such as industrial yeast strains. The pMEC1135 was used in Pereira et al. 2016
The pMEC1049 vector expresses four genes :
Gene | Enzyme | Acronym 
-------------------------------------------------- |-------------------|---
SsXYL1_N272D |D-xylose reductase |XR
SsXYL2 |xylitol dehydrogenase |XDH 
ScXKS1 |Xylulokinase |XK 
ScTAL1 |Transaldolase |tal1p
This plasmid wrongly designated pMEC149 in Table 1 of the publication.
Below is an exerpt from the materials section:
The hphMX4 hygromycin resistance cassette was amplified from plasmid
pAG32 (Goldstein and McCusker, 1999) with primers pYPK0_hygfwd
and pYPK0_hygrev. The PCR product was transformed
together with plasmid pMEC1035 (Pereira et al., submitted) into
S. cerevisiae CEN.PK 113-5D (van Dijken et al., 2000).

pMEC1035 = pMEC1135

The sequence of the pMEC1049 vector is assembled below based on this description.
The primers mentioned are the primers below. 
The two primers used are the 807 and 806 primers.
The systematic name for this vextor is:
pYPK4-ScTEF1-XR(YpDR7)-ScTDH3-XDH-ScPGI1-XK-ScFBA1-TAL1-ScPDC1(all tp PacI)(hyg+)
End of explanation
"""


from pydna.readers import read

pAG32 = read("pAG32.gb")

pAG32

"""
Explanation: The pAG32 sequence is read from a local file below. This sequence is available from EUROSCARF or Addgene. The pAG32 was described in Goldstein and McCusker 1999.
End of explanation
"""


from pydna.download import download_text

pMEC1135 = read(download_text("https://raw.githubusercontent.com/MetabolicEngineeringGroupCBMA/ypk-xylose-pathways/master/notebooks/pMEC1135.gb"))           

pMEC1135

pMEC1135.cseguid()

"""
Explanation: The pMEC1135 vector expresses the XYL1, XYL2, XKS1 and TAL1 genes and is also from the Github repository for Pereira et al. 2016. This vector is described here.
End of explanation
"""


from pydna.amplify import pcr

hygromycin_product = pcr(f, r, pAG32)

"""
Explanation: A PCR product containing the hygromycin resistance gene is amplified by PCR using the primers f and r described above.
End of explanation
"""


from pydna.assembly import Assembly

asm_hyg = Assembly((pMEC1135, hygromycin_product, pMEC1135))

asm_hyg

"""
Explanation: The PCR product is joined with circular pMEC1135 vector by homologous recombination.
End of explanation
"""


candidate = asm_hyg.assemble_linear()[0]

candidate.figure()

"""
Explanation: All the recombination products are linear since the assembly algorithm assumes that all starting fragments are linear. The correct result is the largest linear product (15488 bp).
End of explanation
"""


pMEC1049 = candidate.looped().synced(pMEC1135)

pMEC1049.locus = "pMEC1049"

pMEC1049.stamp()

pMEC1049.write("pMEC1049.gb")

"""
Explanation: We use the looped method to form a circular molecule.
End of explanation
"""


