File: split_fasta.pl

package info (click to toggle)
kissplice 2.6.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,752 kB
  • sloc: cpp: 8,783; python: 1,618; perl: 389; sh: 72; makefile: 18
file content (47 lines) | stat: -rw-r--r-- 1,145 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -w

#break fasta file containing cycles into two fasta files
#file 1: upper paths of cycles
#file 2: lower paths of cycles

if(@ARGV !=3){
print "format:filter_coherence.pl inputfasta.pl upper.fa lower.fa \n";
print "Please specify the names of the input file and the output files\n"; 
exit 1;
}

$infile=shift;  #idio me $infile=$ARGV[0]
#idio me $outfile= $ARGV[1]

$outfile1=shift;
$outfile2=shift;

open(IN, "$infile") || die "Cannot open: $!\n";
open (OUT1,">$outfile1") || die "Cannot open: $!\n";
open(OUT2, ">$outfile2") || die "Cannot open: $!\n";

#>Cycle_31936_upper_Length:93_coverage1:24_coverage2:34
#ACCTTCCAGCTGGCGGTGGCTATCATTGATCGCTACCTGCAGGTGGTCAGGGACACCAAACGCACGTACTTGCAATTGGTGGGAGTGACAGCA
#>Cycle_31936_lower_Length:93_coverage1:23_coverage2:30
#ACCTTCCAGCTGGCGGTGGCTATCATTGATCGCTACCTGCAGGCGGTCAAGGACACCAAACGCACGTACTTGCAATTGGTGGGAGTGACAGCA


while($line=<IN>){
chomp($line);
if ($line=~m/^>Cycle_(\d+)_upper_(.*)/){

print  OUT1 "$line";
print OUT1 "\n";
$line=<IN>;
print  OUT1 "$line";
}

if ($line=~m/^>Cycle_(\d+)_lower_(.*)/){

print  OUT2 "$line";
print OUT2 "\n";
$line=<IN>;
print  OUT2 "$line";
}

}