Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • mdom88
    Junior Member
    • Jul 2021
    • 1

    Adding Features to a GenBank File - Any Help?

    Hi all!

    I'm currently working with a multi entry genbank file and two dataframes in order to add new qualifiers to the genbank file via its key/value system.

    Each entry is a contig, and so far I am able to add new keys on top of the already existing "locus_tag" and "translation" for each entry. However, I am having some difficulties adding values from the dataframes to each contigs.

    Each dataframe is made of 3 columns but holds 6000+ lines of data. I am able to insert one specific column into the genbank file, but these 6000 lines print for every contig.

    I've tried making a for loop, but the 6000 lines continue to print and I am not sure what else to do. Any help would be greatly appreciated!


    This is the code I am working with:

    import os
    from Bio.Seq import Seq
    from Bio.SeqRecord import SeqRecord
    from Bio.SeqFeature import SeqFeature, FeatureLocation
    from Bio import SeqIO
    import pandas as pd
    df1 = pd.read_csv("-f_besthit.csv")
    df2 = pd.read_csv("-f_filtered.csv")
    annotation_handle = open("META.gbk","r")
    recs = [rec for rec in SeqIO.parse("META.gbk", "genbank")]
    my_start_pos = (2)
    my_end_pos = (6)
    my_feature_location = FeatureLocation(my_start_pos,my_end_pos)
    for rec in recs:

    my_feature_type = "CDS"
    full_product={"full_product":"df_best[full_product]","complement":"(1..423)", "locus_tag":"contig", "besthit":"df_fil[besthit]"}
    my_feature = SeqFeature(my_feature_location,type=my_feature_type, qualifiers=full_product)
    besthit={"besthit":"df_fil[besthit]"}
    my_feature_one = SeqFeature(my_feature_location,type=my_feature_type, qualifiers=besthit)

    rec.features.append(my_feature)
    feats = [feat for feat in rec.features if feat.type == "CDS"]
    for feat in feats:
    print(feat)
    for record in SeqIO.parse(annotation_handle,"genbank"):

    a = len(record.features)

    for_rast = open("META.gbk","w")
    x = 0
    final_features = []

    for f in record.features:
    if f.type == "CDS":
    f.qualifiers["full_product"] = "%s_%s" % (df2.loc[:,"besthit"], x+1)
    x += 1
    for f in record.features:
    if f.qualifiers["full_product"] == df2.loc[:"orf"]:
    final_features.append(f)
    else:
    pass


    record.features = final_features
    with open("META.gbk","w") as for_rast:
    SeqIO.write(record, for_rast, "genbank")

Latest Articles

Collapse

  • SEQadmin2
    Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
    by SEQadmin2



    Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
    ...
    Yesterday, 11:10 AM
  • SEQadmin2
    Cancer Drug Resistance: The Lingering Barrier to Rising Survival
    by SEQadmin2



    Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

    There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
    07-08-2026, 05:17 AM
  • GATTACAT
    Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
    by GATTACAT
    Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
    07-01-2026, 11:43 AM

ad_right_rmr

Collapse

News

Collapse

Topics Statistics Last Post
Started by SEQadmin2, Yesterday, 10:04 AM
0 responses
10 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 07-08-2026, 10:08 AM
0 responses
7 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 07-07-2026, 11:05 AM
0 responses
15 views
0 reactions
Last Post SEQadmin2  
Started by SEQadmin2, 07-02-2026, 11:08 AM
0 responses
31 views
0 reactions
Last Post SEQadmin2  
Working...