repo.or.cz
/
GalaxyCodeBases.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
limit fstBC to 30bp in Python3 ver.
[GalaxyCodeBases.git]
/
perl
/
etc
/
WoodyMiaoLin
/
PbeBefore2015
/
convert_fasta_to_nexus.pl
blob
03adea906a1a8bab7a840bb1f14d421711df6d26
1
#!/usr/bin/perl
2
use
strict
;
3
use
warnings
;
4
5
my
$i
=
shift
;
6
my
$o
=
shift
;
7
8
open my
$i1
,
"<"
,
"
$i
"
;
9
open
O
,
">"
,
"
$o
"
;
10
11
my
$nchar
;
12
my
%dna
= %{&
readfasta
(
$i1
)};
13
close
$i1
;
14
my
$ntax
=
keys
%dna
;
15
16
print
O
"#NEXUS
17
BEGIN DATA;
18
Dimensions ntax=
$ntax
nchar=
$nchar
;
19
Format datatype=DNA gap=- missing=?;
20
Matrix
\n
"
;
21
22
foreach
(
sort keys
%dna
) {
23
print
O
"
$_
\t
$dna
{
$_
}
\n
"
;
24
}
25
print
O
";
\n
END;
\n
"
;
26
close
O
;
27
28
sub
readfasta
{
29
my
$in
=
$_
[
0
];
30
my
%fa
;
31
while
(<
$in
>) {
32
$/ =
">"
;
33
my
$seq
= <
$in
>;
34
chomp
$seq
;
35
$seq
=~
s/\s//g
;
36
$/ =
"
\n
"
;
37
$nchar
=
length
$seq
unless
$nchar
;
38
s/>//
;
39
/^(\S+)\s/
;
40
$fa
{
$1
} =
$seq
;
41
}
42
return
\
%fa
;
43
}