예제 #1
0
 def _init_design(self) -> Structure:
     """ convert into nanodesign structure"""
     converter = Converter()
     converter.modify = True
     converter.read_cadnano_file(self.json, None, self.seq)
     converter.dna_structure.compute_aux_data()
     return converter.dna_structure
def write_colored_json(data, dna_structure, colormap, output_file, limits): # write cadnano file colorcoded using a 2D list [[index, value], [index+1, value],...]
    if len(limits)>0: 
        x_min = limits[0]
        x_max = limits[1]
    else: # if no limits are given, use max and min
        x_min = min([data[i][1] for i in range(len(data))])
        x_max = max([data[i][1] for i in range(len(data))])
    dna_structure_out = dna_structure
    for i in range(len(data)):
        x = data[i][1]
        colorindex = int(254*(x-x_min)/(x_max-x_min))+1 # asumin 0-255 colors in colormap
        dna_structure_out.strands[data[i][0]].color = list(colormap(colorindex)[0:-1])                
       
    con = Converter()
    con.dna_structure = dna_structure_out
    con.write_cadnano_file(output_file)
예제 #3
0
def read_file(args, logger):
    """ Read in a cadnano file. """
    converter = Converter()
    logger = logging.getLogger('nanodesign.visualizer')
    converter.logger = logger

    if args.infile == None:
        logger.error("No input file name given.")
        sys.exit(1)
    else:
        logger.info("Input file name: %s" % args.infile)
        infile = args.infile

    converter.read_cadnano_file( args.infile, args.inseqfile, args.inseqname )

    return converter
예제 #4
0
    def _create_hps_modifications(self) -> Tuple[List, List]:
        """ create a list of all modified cadnano bases positions."""
        # TODO: implement without reusing converter
        converter = Converter()
        converter.modify = False
        converter.read_cadnano_file(self.json, None, self.seq)
        converter.dna_structure.compute_aux_data()
        dna_structure_del_ins = converter.dna_structure

        hps_deletions = list()
        hps_insertions = list()
        for strand in dna_structure_del_ins.strands:
            for base in strand.tour:
                if base.num_insertions != 0:
                    hps_insertions.append(_hps(base))
                elif base.num_deletions != 0:
                    hps_deletions.append(_hps(base))
        return hps_deletions, hps_insertions
예제 #5
0
def read_file(file_name, seq_name):
    """ Read in a cadnano file. """
    converter = Converter()
    seq_file = None
    converter.read_cadnano_file(file_name, seq_file, seq_name)
    return converter
def read_file(file_name, seq_name): # read file
    converter = Converter()
    seq_file = None
    converter.read_cadnano_file(file_name, seq_file, seq_name)
    return converter