-
Notifications
You must be signed in to change notification settings - Fork 158
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
779b3bf
commit 54706b5
Showing
8 changed files
with
157 additions
and
36 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
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
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
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
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 |
---|---|---|
|
@@ -119,7 +119,7 @@ Usage | |
``` | ||
fakit -- a cross-platform and efficient suit for FASTA/Q file manipulation | ||
Version: 0.2.3 | ||
Version: 0.2.4 | ||
Author: Wei Shen <[email protected]> | ||
|
@@ -134,7 +134,8 @@ Available Commands: | |
faidx create FASTA index file | ||
fq2fa covert FASTQ to FASTA | ||
fx2tab covert FASTA/Q to tabular format (with length/GC content/GC skew) | ||
grep search sequences by pattern(s) of name or sequence motifs | ||
grep search sequences by pattern(s) of name or sequence motifss | ||
head print first N FASTA/Q records | ||
locate locate subsequences/motifs | ||
rename rename duplicated IDs | ||
replace replace name/sequence/by regular expression | ||
|
@@ -960,6 +961,12 @@ Flags: | |
|
||
Examples | ||
|
||
1. Sample by proportion | ||
|
||
$ zcat hairpin.fa.gz | fakit sample -p 0.1 -o sample.fa.gz | ||
[INFO] sample by proportion | ||
[INFO] 2814 sequences outputed | ||
|
||
1. Sample by number | ||
|
||
$ zcat hairpin.fa.gz | fakit sample -n 1000 -o sample.fa.gz | ||
|
@@ -968,11 +975,9 @@ Examples | |
|
||
***To reduce memory usage when spliting big file, we could use flag `--two-pass`*** | ||
|
||
1. Sample by proportion | ||
***We can also use `fakit sample -p` followed with `fakit head -n`:*** | ||
|
||
$ zcat hairpin.fa.gz | fakit sample -p 0.1 -o sample.fa.gz | ||
[INFO] sample by proportion | ||
[INFO] 2814 sequences outputed | ||
$ zcat hairpin.fa.gz | fakit sample -p 0.1 | fakit head -n 1000 -o sample.fa.gz | ||
|
||
1. Set rand seed to reproduce the result | ||
|
||
|
@@ -985,6 +990,46 @@ Examples | |
Note that when sampling on FASTQ files, make sure using same random seed by | ||
flag `-s` (`--rand-seed`) | ||
|
||
## head | ||
|
||
Usage | ||
|
||
``` | ||
print first N FASTA/Q records | ||
Usage: | ||
fakit head [flags] | ||
Flags: | ||
-n, --number int print first N FASTA/Q records (default 10) | ||
``` | ||
|
||
Examples | ||
|
||
1. FASTA | ||
|
||
$ fakit head -n 1 hairpin.fa.gz | ||
>cel-let-7 MI0000001 Caenorhabditis elegans let-7 stem-loop | ||
UACACUGUGGAUCCGGUGAGGUAGUAGGUUGUAUAGUUUGGAAUAUUACCACCGGUGAAC | ||
UAUGCAAUUUUCUACCUUACCGGAGACAGAACUCUUCGA | ||
|
||
1. FASTQ | ||
|
||
$ fakit head -n 1 reads_1.fq.gz | ||
@HWI-D00523:240:HF3WGBCXX:1:1101:2574:2226 1:N:0:CTGTAG | ||
TGAGGAATATTGGTCAATGGGCGCGAGCCTGAACCAGCCAAGTAGCGTGAAGGATGACTG | ||
CCCTACGGGTTGTAAACTTCTTTTATAAAGGAATAAAGTGAGGCACGTGTGCCTTTTTGT | ||
ATGTACTTTATGAATAAGGATCGGCTAACTCCGTGCCAGCAGCCGCGGTAATACGGAGGA | ||
TCCGAGCGTTATCCGGATTTATTGGGTTTAAAGGGTGCGCAGGCGGT | ||
+ | ||
HIHIIIIIHIIHGHHIHHIIIIIIIIIIIIIIIHHIIIIIHHIHIIIIIGIHIIIIHHHH | ||
HHGHIHIIIIIIIIIIIGHIIIIIGHIIIIHIIHIHHIIIIHIHHIIIIIIIGIIIIIII | ||
HIIIIIGHIIIIHIIIH?DGHEEGHIIIIIIIIIIIHIIHIIIHHIIHIHHIHCHHIIHG | ||
IHHHHHHH<GG?B@EHDE-BEHHHII5B@GHHF?CGEHHHDHIHIIH | ||
|
||
|
||
|
||
## replace | ||
|
||
Usage | ||
|
Submodule site
updated
from 006cf5 to 24341f
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,83 @@ | ||
// Copyright © 2016 Wei Shen <[email protected]> | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package cmd | ||
|
||
import ( | ||
"runtime" | ||
|
||
"github.com/brentp/xopen" | ||
"github.com/shenwei356/bio/seq" | ||
"github.com/shenwei356/bio/seqio/fastx" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// headCmd represents the head command | ||
var headCmd = &cobra.Command{ | ||
Use: "head", | ||
Short: "print first N FASTA/Q records", | ||
Long: `print first N FASTA/Q records | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
config := getConfigs(cmd) | ||
alphabet := config.Alphabet | ||
idRegexp := config.IDRegexp | ||
chunkSize := config.ChunkSize | ||
bufferSize := config.BufferSize | ||
lineWidth := config.LineWidth | ||
outFile := config.OutFile | ||
seq.AlphabetGuessSeqLenghtThreshold = config.AlphabetGuessSeqLength | ||
seq.ValidateSeq = false | ||
runtime.GOMAXPROCS(config.Threads) | ||
|
||
number := getFlagPositiveInt(cmd, "number") | ||
|
||
files := getFileList(args) | ||
|
||
outfh, err := xopen.Wopen(outFile) | ||
checkError(err) | ||
defer outfh.Close() | ||
|
||
i := 0 | ||
for _, file := range files { | ||
fastxReader, err := fastx.NewReader(alphabet, file, bufferSize, chunkSize, idRegexp) | ||
checkError(err) | ||
for chunk := range fastxReader.Ch { | ||
checkError(chunk.Err) | ||
|
||
for _, record := range chunk.Data { | ||
i++ | ||
record.FormatToWriter(outfh, lineWidth) | ||
|
||
if number == i { | ||
fastxReader.Cancel() | ||
return | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(headCmd) | ||
headCmd.Flags().IntP("number", "n", 10, "print first N FASTA/Q records") | ||
} |
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 |
---|---|---|
|
@@ -32,10 +32,10 @@ import ( | |
// RootCmd represents the base command when called without any subcommands | ||
var RootCmd = &cobra.Command{ | ||
Use: "fakit", | ||
Short: "a cross-platform and efficient suit for FASTA/Q file manipulation", | ||
Long: `fakit -- a cross-platform and efficient suit for FASTA/Q file manipulation | ||
Short: "a cross-platform and efficient toolkit for FASTA/Q file manipulation", | ||
Long: `fakit -- a cross-platform and efficient toolkit for FASTA/Q file manipulation | ||
Version: 0.2.3 | ||
Version: 0.2.4 | ||
Author: Wei Shen <[email protected]> | ||
|