def test_CreateFromSeqRecord(self):
    
        with GeneSequenceApp.app.test_request_context("/"):
            GeneSequenceApp.app.preprocess_request()
            
            with open(__location__ + "/testfiles/422900759.pickle", 'rb') as f:
                record = pickle.load(f)

            GenBankEntry.create_from_seqrecord(record, "")
            entry = Sequence.create_from_seqrecord(record)
            self.assertEqual(entry.Sequence, str(record.seq))
def render_sequences_view(genbank_id):
	if GenBankEntry.exists(genbank_id):
		sequences = Sequence.get_for_genbank_id(genbank_id)
		return render_template(
			"sequence.view.template.html", title = "Sequences", genbank_id=genbank_id, sequences=sequences)
	else:
		return render_template(
			"sequence.view.template.html", title = "Sequences", genbank_id=genbank_id, sequences=sequences)
def render_sequence_add():
	form_to_validate = SequenceEntryForm(GenBankEntry.all())

	if form_to_validate.validate_on_submit():
		try:
			Sequence.add(form.genbank_id.data, form.sequence.data)
		except:
			return render_template("sequence.view.template.html", title = "Sequences")
	else:
		return render_template("sequence.form.template.html", title = "Add new sequence", form=form_to_validate)
def try_add_from_genbank(id, silk_type):

	get_module_logger().info("Calling entrez for ID {}".format(id))
	fasta = entrez_get_fasta_seqrecord(id)
	success = False

	if fasta is not None:
		get_module_logger().info("Data for ID {} found. Trying to add to database.".format(id))
		try:
			get_module_logger().info("Creating GenBankEntry.")
			GenBankEntry.create_from_seqrecord(fasta, silk_type)
			get_module_logger().info("Creating Sequence.")
			Sequence.create_from_seqrecord(fasta)
			success = True
		except:
			raise
	else:
		get_module_logger().info("Data for ID {} not found.")

	return success
def render_genbank_view():
	entries = GenBankEntry.all()

	get_module_logger().info("Rendering table for {} GenBank entries.".format(len(entries)))

	return render_template("genbank.view.template.html", title = "GenBank Interface", genbank_entries = entries)
 def setUp(self):
     self.db_fd, GeneSequenceApp.app.config['DATABASE'] = tempfile.mkstemp()
     self.app = GeneSequenceApp.app.test_client()
     GeneSequenceApp.db.create_if_not_exists(True)
     GenBankEntry.fill_db_with_test_data()
     self.fill_db_with_test_data()