-1
$\begingroup$

I have a list of gene names which I know are present in a genbank file. I want to order these genes based on the order of their presence in the genbank. This should also account for whether they are on the positive or negative strand. So for example I have four genes; genes_1? are on the positive strand and genes_2? are negative

>nano Gene_names.txt
gene_1A  #assume this is the first gene for positive strand
gene_1B  
gene_2A #assume this is first gene for negative strand
gene_2B 


>nano Desired_out.txt
gene_1A
gene_2B
gene_1B
gene_2A

enter image description here

Edits

The genbank would be the standard flat file as linked below by terdon. The gene names are from a text list file and I have edited them now to reflect this.Im not exactly sure how to approach the strandness issue but I would imagine the complement would be helpful. I am unsure as to the strandness of the genes as is.

A working example of my work is to get the order of SpoI-V and other sporulation genes from C. difficile 630

e.g. sigE, sigG, spoIIE, sleC

$\endgroup$
1
  • 1
    $\begingroup$ Please edit your question and clarify. I assume you mean a genbank flat file, like this one, right? If so, why does your example have a fasta-like header? Should we be looking for the "complement" field to get the strand? And should there always be one +, then one -, then one + and so on? What if there are more genes on one strand than on the other? Can you add an actual example of your data so we understand what you need? $\endgroup$
    – terdon
    Commented Feb 6, 2018 at 18:14

1 Answer 1

1
$\begingroup$

I can't quite grok your sorting scheme, but you can use genbankr to read your genbank file into a genomic ranges object in R, and filter/sort it however you like:

source("https://bioconductor.org/biocLite.R")
biocLite("genbankr")
library(genbankr)
gb = readGenBank("sequence.gb")
subset(cds(gb), gene %in% c('sigE', 'sigG', 'spoIIE', 'sleC', 'REV7'))

output:

GRanges object with 1 range and 10 metadata columns:
      seqnames       ranges strand |        type        gene        note
         <Rle>    <IRanges>  <Rle> | <character> <character> <character>
  [1]       IX [3300, 4037]      - |         CDS        REV7        <NA>
      codon_start     product  protein_id   translation     loctype
        <numeric> <character> <character> <AAStringSet> <character>
  [1]           1       Rev7p  AAA98667.1     MNR...SLF      normal
          gene_id transcript_id
      <character>   <character>
  [1]        REV7        REV7.1
  -------
  seqinfo: 1 sequence from U49845.1 genome
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.