[PYTHON] Script to change the description of fasta

Fasta problem where Description is in a separate file

In some databases, only the ID is described in fasta, and the Description corresponding to that ID may be in a separate file.

http://genome.jgi.doe.gov/Creinhardtii/download/_JAMO/585473eb7ded5e78cff8c450/Creinhardtii_281_v5.5.annotation_info.txt?requestTime=1491367905

This can be useful AHRD (https://github.com/groupschoof/AHRD/blob/master/README.textile) Because it is not suitable for optimizing annotations using I wrote the following script that fuses the two files.

fasta_annotation_merge.py


#!/usr/bin/env python
# -*- coding: utf-8 -*-

#fasta_Change annotation information with id item as key

import sys
from Bio import SeqIO
import csv


fasta_in = sys.argv[1]                            #In the first argument, specify the fasta file you want to change.
changer_in = sys.argv[2]                          #Tab-separated keyID in the second argument\t Specify the file that describes Annotation

for q in open(changer_in, "r"):                     #Open annotation information file
    change = q.split('\t')        #Put in the change list separated by tabs
    for record in SeqIO.parse(fasta_in, 'fasta'): #Open fasta file Parse using SeqIO(Read one item at a time)
        id_part = record.id                       #Read the ID part of fasta
        seq = record.seq                          #Read the array part of fastan
        if id_part == change[0]:            #If the id part of the fasta file and the id part of the changer item match. ..
                fasta_seq = '>' + id_part + ' '+ change[1] + '\n' + seq + '\n'     #Arrange in fasta format
                print(fasta_seq)                  #Output fasta to standard output

Recommended Posts

Script to change the description of fasta
Change the decimal point of logging from, to.
Template of python script to read the contents of the file
Change the theme of Jupyter
Change the style of matplotlib
Script to get the expiration date of the SSL certificate
[Python] Change the Cache-Control of the object uploaded to Cloud Storage
An introduction to object orientation-let's change the internal state of an object
Change the volume of Pepper according to the surrounding environment (sound)
Change the Flyweight pattern to Pythonic (?) (3)
Change the Flyweight pattern to Pythonic (?) (2)
Change the background of Ubuntu (GNOME)
Change the Python version of Homebrew
Change the Flyweight pattern to Pythonic (?) (1)
Change the suffix of django-filter / DateFromToRangeFilter
Supplement to the explanation of vscode
[Python] Change the alphabet to numbers
How to change the log level of Azure SDK for Python
How to change the color of just the button pressed in Tkinter
Conditional branch due to the existence of a shell script file
Change the Y-axis scale of Matplotlib to exponential notation (10 Nth power notation)
Find out the mystery change of Pokédex description by Levenshtein distance
Feel free to change the label of the legend in Seaborn in python
[Go] Create a CLI command to change the extension of the image
I summarized how to change the boot parameters of GRUB and GRUB2
Consider the description of Dockerfile (Django + MySQL②)
Change the length of Python csv strings
The story of trying to reconnect the client
10 methods to improve the accuracy of BERT
How to check the version of Django
The story of adding MeCab to ubuntu 16.04
Change the order of PostgreSQL on Heroku
The story of pep8 changing to pycodestyle
Change the destination batfish server of pybatfish
Consider the description of docker-compose.yml (Django + MySQL ③)
Semi-automatically generate a description of the package to be registered on PyPI
When you want to change the HTTP headers of Flask's test client
How to calculate the volatility of a brand
Example of what to do when the sample script does not work (OpenCV-Python)
How to find the area of the Voronoi diagram
Combinatorial optimization to find the hand of "Millijan"
Setting to output the log of cron execution
[Python] How to change the date format (display format)
The inaccuracy of Tensorflow was due to log (0)
Change the font size of the legend in df.plot
Change the Key of Object on S3 from normal date format to Hive format
Set the range of active strips to the preview range
I tried to touch the API of ebay
Change the color of Fabric errors and warnings
I tried to correct the keystone of the image
Script to tweet with multiples of 3 and numbers with 3 !!
Change the data frame of pandas purchase data (id x product) to a dictionary
Python script to get a list of input examples for the AtCoder contest
General description of the CPUFreq core and CPUFreq notifiers
How to change the appearance of unselected Foreign Key fields in Django's ModelForm
Change the resolution of Ubuntu running on VirtualBox
To get the path of the currently running python.exe
Ansible self-made module creation-Part 3: Life that wants to judge the necessity of change-
I made a script to record the active window using win32gui of Python
I want to customize the appearance of zabbix
From the introduction of pyethapp to the execution of contract