예제 #1
0
    def export( self ):
        print( "Exporting..." )

        # Get all transcript IDs
        results = db_session.query( Transcript.id ).all()

        n = 0

        target_filepath = settings.data_folder + "/transcripts.fasta"

        output_handle = open( target_filepath, "w" )
        for result in results:
            transcript_id = result[ 0 ]
            seq_record = Transcript( transcript_id ).get_sequence()

            if seq_record is None:
                print( "Missing sequence for [" + transcript_id + "]" )
                continue

            seq_record.id = transcript_id
            SeqIO.write( seq_record, output_handle, "fasta" )

            n += 1
            if n % 100 == 0:
                print( "[{}] sequences written".format( n ) )

        output_handle.close()

        print( "...Saved transcripts to [{}]".format( target_filepath ) )
예제 #2
0
	def export(self):
		print("Exporting...")

		from Bio import SeqIO
		from database import db_session
		from models import Transcript
		import settings 

		# Get all transcript IDs
		results = db_session \
			.query(Transcript.id) \
			.all()

		n = 0

		target_filepath = settings.data_folder+"/transcripts.fasta"

		output_handle = open(target_filepath, "w")
		for result in results:
			transcript_id = result[0]
			seq_record = Transcript(transcript_id).get_sequence()
			
			if seq_record == None:
				print ("Missing sequence for ["+transcript_id+"]")
				continue

			seq_record.id = transcript_id
			SeqIO.write(seq_record, output_handle, "fasta")

			n += 1
			if n % 100 == 0:
				print("["+str(n)+"] sequences written")

		output_handle.close()

		print("...Saved transcripts to ["+target_filepath+"]")