-
Notifications
You must be signed in to change notification settings - Fork 4
/
test-fasta-reader.py
executable file
·54 lines (42 loc) · 2.01 KB
/
test-fasta-reader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
#=========================================================================
# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
# License (GPL) version 3, as described at www.opensource.org.
# Copyright (C)2016 William H. Majoros ([email protected]).
#=========================================================================
from __future__ import (absolute_import, division, print_function,
unicode_literals, generators, nested_scopes, with_statement)
from builtins import (bytes, dict, int, list, object, range, str, ascii,
chr, hex, input, next, oct, open, pow, round, super, filter, map, zip)
from FastaReader import FastaReader
from FastaWriter import FastaWriter
from Translation import Translation
#filename="/home/bmajoros/1000G/assembly/combined/HG00096/1.fasta"
#reader=FastaReader("/home/bmajoros/1000G/assembly/combined/HG00096/1.fasta")
#while(True):
# [defline,seq]=reader.nextSequence()
# if(not defline): break
# print("defline="+defline);
# L=len(seq)
# print("length="+str(L))
#filename="/home/bmajoros/1000G/assembly/BRCA1-NA19782.fasta";
filename="/Users/bmajoros/python/test/data/subset.fasta"
print(FastaReader.getSize(filename))
[defline,seq]=FastaReader.firstSequence(filename)
print(len(seq))
#filename="/home/bmajoros/1000G/assembly/test.fasta"
filename="/Users/bmajoros/python/test/data/subset.fasta"
hash=FastaReader.readAllAndKeepDefs(filename)
for key in hash.keys():
[defline,seq]=hash[key]
print(defline)
[id,attrs]=FastaReader.parseDefline(defline)
print("id="+id)
for key,value in attrs.items():
print(key+"="+value)
writer=FastaWriter()
writer.writeFasta(">ABCD","ATCGATCGTAGCTAGTCTGCGCGTATCGTCAGTCTCTATCGATCGTACTGCGATCTAGCTAGCTGATCGTAGCTTCTATGACTGCTAGTCATCTAGCTAGCTGATCGTAGCTGCGCGCGATATATTGCATCTATGCTATCATTGCATGCTAGCTCTAGCTAGTCGATGCTATCTTAGCTAC","test1.fasta")
writer.appendToFasta(">XYZ","GATTACA","test1.fasta")
print(Translation.translate(seq))
print("forward:",seq)
print("revcomp: ",Translation.reverseComplement(seq))