import json
import re
from dna_features_viewer import GraphicFeature, GraphicRecord, CircularGraphicRecord
import Bio
from Bio.Seq import Seq
import sys

filename = sys.argv[1]

with open(filename) as f:
    data = json.load(f)

sol = data['solutions']
frag = sol[0]['fragments']
seq = Seq(data['seq'])

#lists to store inputs for dna_features_viewer
start_list = []
end_list = []
strand_list =[]
label_list=[]
color_list = ["#DFFF00", "#6495ED", "#FFBF00", "#40E0D0", "#FF7F50", "#9FE2BF", "#DE3163", "#CCCCFF", "#800080", "#008080", "#00FF00", "#00FFFF", "#000080"]

# For each fragment
for i in range(len(frag)):
    fragment = frag[i]
    substring = Seq(fragment['seq'])
    start_list.append(seq.find(substring[:40]))
    end_index = seq.find(substring[:40])+len(substring)
    # Make sure the sequences are aligned properly - sometimes they could wrap around each other since this is a circular plasmid
    if end_index < len(seq):
        end_list.append(end_index)
    else:
        end_list.append(end_index-len(seq))
    strand_list.append("+1")
    description = "type: " + fragment['type']+", cost: " + str(fragment['cost'])
    if fragment['type'] == "pcr":
        description += ", url: "
        description += fragment['url']
    label_list.append(description)

for i in range(len(start_list)):
    if start_list[i] > end_list[i]:
        start_list[i] = start_list[i] - len(seq)

# Build the list of features
features1 = [GraphicFeature(start = start_list[i], end = end_list[i], strand = +1, color = color_list[i], label = label_list[i]) for i in range(len(frag))]

# Create the record
record = CircularGraphicRecord(sequence_length = len(seq), features = features1)

# Plot the record and save it to disk
record.plot(figure_width=10)
ax, _ = record.plot(figure_width=5)
ax.figure.savefig(filename + "_vis.png", bbox_inches="tight")

2a60c4f996e8fc3e993e120c49ed20235ec75371
<mask token>

<mask token>
with open(filename) as f:
    data = json.load(f)
<mask token>
for i in range(len(frag)):
    fragment = frag[i]
    substring = Seq(fragment['seq'])
    start_list.append(seq.find(substring[:40]))
    end_index = seq.find(substring[:40]) + len(substring)
    if end_index < len(seq):
        end_list.append(end_index)
    else:
        end_list.append(end_index - len(seq))
    strand_list.append('+1')
    description = 'type: ' + fragment['type'] + ', cost: ' + str(fragment[
        'cost'])
    if fragment['type'] == 'pcr':
        description += ', url: '
        description += fragment['url']
    label_list.append(description)
for i in range(len(start_list)):
    if start_list[i] > end_list[i]:
        start_list[i] = start_list[i] - len(seq)
<mask token>
record.plot(figure_width=10)
<mask token>
ax.figure.savefig(filename + '_vis.png', bbox_inches='tight')

<mask token>
filename = sys.argv[1]
with open(filename) as f:
    data = json.load(f)
sol = data['solutions']
frag = sol[0]['fragments']
seq = Seq(data['seq'])
start_list = []
end_list = []
strand_list = []
label_list = []
color_list = ['#DFFF00', '#6495ED', '#FFBF00', '#40E0D0', '#FF7F50',
    '#9FE2BF', '#DE3163', '#CCCCFF', '#800080', '#008080', '#00FF00',
    '#00FFFF', '#000080']
for i in range(len(frag)):
    fragment = frag[i]
    substring = Seq(fragment['seq'])
    start_list.append(seq.find(substring[:40]))
    end_index = seq.find(substring[:40]) + len(substring)
    if end_index < len(seq):
        end_list.append(end_index)
    else:
        end_list.append(end_index - len(seq))
    strand_list.append('+1')
    description = 'type: ' + fragment['type'] + ', cost: ' + str(fragment[
        'cost'])
    if fragment['type'] == 'pcr':
        description += ', url: '
        description += fragment['url']
    label_list.append(description)
for i in range(len(start_list)):
    if start_list[i] > end_list[i]:
        start_list[i] = start_list[i] - len(seq)
features1 = [GraphicFeature(start=start_list[i], end=end_list[i], strand=+1,
    color=color_list[i], label=label_list[i]) for i in range(len(frag))]
record = CircularGraphicRecord(sequence_length=len(seq), features=features1)
record.plot(figure_width=10)
ax, _ = record.plot(figure_width=5)
ax.figure.savefig(filename + '_vis.png', bbox_inches='tight')

import json
import re
from dna_features_viewer import GraphicFeature, GraphicRecord, CircularGraphicRecord
import Bio
from Bio.Seq import Seq
import sys
filename = sys.argv[1]
with open(filename) as f:
    data = json.load(f)
sol = data['solutions']
frag = sol[0]['fragments']
seq = Seq(data['seq'])
start_list = []
end_list = []
strand_list = []
label_list = []
color_list = ['#DFFF00', '#6495ED', '#FFBF00', '#40E0D0', '#FF7F50',
    '#9FE2BF', '#DE3163', '#CCCCFF', '#800080', '#008080', '#00FF00',
    '#00FFFF', '#000080']
for i in range(len(frag)):
    fragment = frag[i]
    substring = Seq(fragment['seq'])
    start_list.append(seq.find(substring[:40]))
    end_index = seq.find(substring[:40]) + len(substring)
    if end_index < len(seq):
        end_list.append(end_index)
    else:
        end_list.append(end_index - len(seq))
    strand_list.append('+1')
    description = 'type: ' + fragment['type'] + ', cost: ' + str(fragment[
        'cost'])
    if fragment['type'] == 'pcr':
        description += ', url: '
        description += fragment['url']
    label_list.append(description)
for i in range(len(start_list)):
    if start_list[i] > end_list[i]:
        start_list[i] = start_list[i] - len(seq)
features1 = [GraphicFeature(start=start_list[i], end=end_list[i], strand=+1,
    color=color_list[i], label=label_list[i]) for i in range(len(frag))]
record = CircularGraphicRecord(sequence_length=len(seq), features=features1)
record.plot(figure_width=10)
ax, _ = record.plot(figure_width=5)
ax.figure.savefig(filename + '_vis.png', bbox_inches='tight')

import json
import re
from dna_features_viewer import GraphicFeature, GraphicRecord, CircularGraphicRecord
import Bio
from Bio.Seq import Seq
import sys

filename = sys.argv[1]

with open(filename) as f:
    data = json.load(f)

sol = data['solutions']
frag = sol[0]['fragments']
seq = Seq(data['seq'])

#lists to store inputs for dna_features_viewer
start_list = []
end_list = []
strand_list =[]
label_list=[]
color_list = ["#DFFF00", "#6495ED", "#FFBF00", "#40E0D0", "#FF7F50", "#9FE2BF", "#DE3163", "#CCCCFF", "#800080", "#008080", "#00FF00", "#00FFFF", "#000080"]

# For each fragment
for i in range(len(frag)):
    fragment = frag[i]
    substring = Seq(fragment['seq'])
    start_list.append(seq.find(substring[:40]))
    end_index = seq.find(substring[:40])+len(substring)
    # Make sure the sequences are aligned properly - sometimes they could wrap around each other since this is a circular plasmid
    if end_index < len(seq):
        end_list.append(end_index)
    else:
        end_list.append(end_index-len(seq))
    strand_list.append("+1")
    description = "type: " + fragment['type']+", cost: " + str(fragment['cost'])
    if fragment['type'] == "pcr":
        description += ", url: "
        description += fragment['url']
    label_list.append(description)

for i in range(len(start_list)):
    if start_list[i] > end_list[i]:
        start_list[i] = start_list[i] - len(seq)

# Build the list of features
features1 = [GraphicFeature(start = start_list[i], end = end_list[i], strand = +1, color = color_list[i], label = label_list[i]) for i in range(len(frag))]

# Create the record
record = CircularGraphicRecord(sequence_length = len(seq), features = features1)

# Plot the record and save it to disk
record.plot(figure_width=10)
ax, _ = record.plot(figure_width=5)
ax.figure.savefig(filename + "_vis.png", bbox_inches="tight")
