def split(args): '''fasta splitting and region splitting, dispatched by main()''' if args.region_length is None: split_fasta(args.fasta,args.num_files,args.per_file) else: split_regions(args.fasta,args.region_length,args.num_files,args.per_file)
def split(args): '''fasta splitting and region splitting, dispatched by main()''' if args.region_length is None: split_fasta(args.fasta, args.num_files, args.per_file) else: split_regions(args.fasta, args.region_length, args.num_files, args.per_file)
def parse_regions(args): '''Takes the region and region_file arguments and parses them into appropriate regions, depending on whcih are specified: - If args.region_file specified, load and use those regions without modification - If region with position info specified directly, use that without modification (eg. 1000:2000 or Lambda_NEB:1000:2000) - If region with name specified but no position, split by max_length using split_regions (eg. `-r Lambda_NEB`) - If no region specified, split all sequences in reference fasta into regions of max_length using split_regions ''' regions = [] # if we specified region files, load regions from there, directly, no modifications if args.region_file is not None: if os.path.isfile(args.region_file): regions += [x.strip() for x in open(args.region_file).readlines()] # if we specified a region with positions directly, just use that reginfo = RegionInfo(args.region) if reginfo.start is not None: regions.append(args.region) # now only split if none specified from file and if args.region does not contain # info if regions == []: # make sure to split the regions up if 'max_length' in args.params: # split the regions if max length specified regions = split_regions(args.ref, args.params['max_length'], userefs=args.region) else: # or use 10kb by default regions = split_regions(args.ref, 10000, userefs=args.region) return regions