Beispiel #1
0
def generate_fasta(logger,internal_services,token,ref,output_dir,obj_name):
	try:
		ga = GenomeAnnotationAPI(internal_services,
                             token=token,
                             ref= "{}/{}".format(ref,obj_name))
	except Exception as e:
		raise Exception("Unable to Call GenomeAnnotationAPI : {0}: {1}".format(e))
	logger.info("Generating FASTA file from Assembly for {}/{}".format(ref,obj_name))	
	fasta_start = datetime.datetime.utcnow()
	output_file = os.path.join(output_dir,'{}.fasta'.format(obj_name))
    	with open(output_file, 'w') as fasta_file:
        	ga.get_assembly().get_fasta().to_file(fasta_file)
	fasta_file.close()
    	fasta_end = datetime.datetime.utcnow()
	logger.info("Generating FASTA for {} took {}".format(obj_name, fasta_end - fasta_start))
	return output_file
def generate_fasta(logger, internal_services, token, ref, output_dir,
                   obj_name):
    try:
        ga = GenomeAnnotationAPI(internal_services,
                                 token=token,
                                 ref="{}/{}".format(ref, obj_name))
    except Exception as e:
        raise Exception(
            "Unable to Call GenomeAnnotationAPI : {0}: {1}".format(e))
    logger.info("Generating FASTA file from Assembly for {}/{}".format(
        ref, obj_name))
    fasta_start = datetime.datetime.utcnow()
    output_file = os.path.join(output_dir, '{}.fasta'.format(obj_name))
    with open(output_file, 'w') as fasta_file:
        ga.get_assembly().get_fasta().to_file(fasta_file)
    fasta_file.close()
    fasta_end = datetime.datetime.utcnow()
    logger.info("Generating FASTA for {} took {}".format(
        obj_name, fasta_end - fasta_start))
    return output_file
Beispiel #3
0
def generate_fasta(logger,internal_services,token,ref,output_dir,obj_name):
	try:
		ga = GenomeAnnotationAPI(internal_services,
                             token=token,
                             ref= ref)
	except Exception as e:
		raise Exception("Unable to Call GenomeAnnotationAPI : {0}".format("".join(traceback.format_exc())))
	logger.info("Generating FASTA file from Assembly for {}".format(obj_name))	
	fasta_start = datetime.datetime.utcnow()
	output_file = os.path.join(output_dir,'{}.fasta'.format(obj_name))
	fasta_file= io.open(output_file, 'wb')
    	try:
        	ga.get_assembly().get_fasta().to_file(fasta_file)
	except Exception as e:
		#raise Exception("Unable to Create FASTA file from Genome Annotation : {0}".format(obj_name))
		raise Exception("Unable to Create FASTA file from Genome Annotation : {0}".format("".join(traceback.format_exc())))
	finally:
		fasta_file.close()
    	fasta_end = datetime.datetime.utcnow()
	logger.info("Generating FASTA for {} took {}".format(obj_name, fasta_end - fasta_start))
	return output_file
    def get_assembly(self, ctx, ref):
        """
        Retrieve the Assembly associated with this GenomeAnnotation.
        @return Reference to AssemblyAPI object
        :param ref: instance of type "ObjectReference"
        :returns: instance of type "ObjectReference"
        """
        # ctx is the context object
        # return variables are: returnVal
        #BEGIN get_assembly
        ga = GenomeAnnotationAPI_local(self.services, ctx['token'], ref)
        returnVal = ga.get_assembly(ref_only=True)
        #END get_assembly

        # At some point might do deeper type checking...
        if not isinstance(returnVal, basestring):
            raise ValueError('Method get_assembly return value ' +
                             'returnVal is not type basestring as required.')
        # return the results
        return [returnVal]
Beispiel #5
0
		gto['domain'] = taxon.get_domain()
	except Exception, e:
		success = 0
	try:
		gto['genetic_code'] = taxon.get_genetic_code()
	except Exception, e:
		success = 0
	try:
		gto['taxonomy'] = ",".join(taxon.get_scientific_lineage())
	except Exception, e:
		success = 0

assemb = {};
success = 0;
try:
	assemb = ga.get_assembly();
	success = 1;
except Exception, e:
	success = 0
	
if success == 1:
	gto['contigobj'] = {
		'id' : sys.argv[6],
		'name' : sys.argv[6],
		'source' : 'KBase',
		'source_id' : sys.argv[6],
		'md5' : "",
		'type' : "Genome",
		'contigs' : []
	};