-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMLST_extractor.py
More file actions
59 lines (51 loc) · 1.63 KB
/
Copy pathMLST_extractor.py
File metadata and controls
59 lines (51 loc) · 1.63 KB
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
51
52
53
54
55
56
57
58
59
import os,sys
from SilicoPCR import *
from Bio import Entrez
from Bio import SeqIO,SeqRecord
from BioWrapper import *
from MLST import *
######################
if __name__ == '__main__':
usage=' python MLST.py ALLELES_DIR GENOME '
primers={
'arcc':['TTGATTCACCAGCGCGTATTGTC','AGGTATCTGCTTCAATCAGCG'] ,
'aroe':['ATCGGAAATCCTATTTCACATTC','GGTGTTGTATTAATAACGATATC'],
'glpf':['CTAGGAACTGCAATCTTAATCC' ,'TGGTAAAATCGCATGTCCAATTC'],
'gmk':['ATCGTTTTATCGGGACCATC' ,'TCATTAACTACAACGTAATCGTA'] ,
'pta':['GTTAAAATCGTATTACCTGAAGG','GACCCTTTTGTTGAAAAGCTTAA'] ,
'tpi':['TCGTTCATTCTGAACGTCGTGAA','TTTGCACCTTCTAACAATTGTAC'] ,
'yqil':['CAGCATACAGGACACCTATTGGC','CGTTGAGGAATCGATACTGGAAC']}
key_order=['arcc',
'aroe',
'glpf',
'gmk',
'pta',
'tpi',
'yqil']
args = sys.argv
if len(args) != 3:
print usage
sys.exit()
inp_dir = args[1]
inp_genome = args[2]
out_file = inp_genome + 'MLST.fasta'
######################
if __name__=='__main__':
ML = Multi_locus(inp_dir)
ML.add_primers(primers)
#genomes=[g for g in os.listdir(inp_genomes_dir)]
#
genome_name=inp_genome.split('/')[-1]
genome_dir='/'.join(inp_genome.split('/')[:-1]) + '/'
mlst_profile=MLST_profile(genome_name)
accessions=get_accessions(genome_name,genome_dir)
genome_seqs=[s.seq.tostring() for s in get_seqs(accessions)]
for locus in ML.loci:
PCR=PCRexperiment(locus.name,locus.primers,accessions,genome_seqs)
amplicon=PCR.amplify()
sequence=PCR.trim(amplicon,locus.borders,locus.marker_length)
if sequence == None: sequence=''
mlst_profile.add_sequence(locus.name,sequence)
mlst_profile.write_fasta(key_order,out_file)
#
print 'task done'