-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19a5926
commit 86927db
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/python2.7 | ||
# coding: utf-8 | ||
|
||
# Simple script to convert csv file to fasta fromat | ||
|
||
# import librarys | ||
import pandas as pd | ||
import sys | ||
import os.path | ||
|
||
# create file name for fasta file | ||
filename = sys.argv[-1] | ||
outname = filename.split('.') | ||
outname1 = '.'.join([outname[0], 'fasta']) | ||
|
||
# read data (csv file) | ||
df = pd.read_csv(filename, header=None) | ||
df.columns = ['id', 'seq'] | ||
|
||
# create fasta file | ||
fh = open(outname1, 'w') | ||
|
||
# function for conversion to fasta format | ||
for i in range(0,len(df)): | ||
n = df.at[i,'id'] | ||
seq = df.at[i, 'seq'] | ||
fh.write(">%s\n" % n) | ||
fh.write("%s\n" % seq) | ||
fh.close() |