Debian Codegraph @

README.md

raw
1 Fastaq
2 ======
3
4 Python3 script to manipulate FASTA and FASTQ (and other format) files, plus API for developers
5
6 Installation
7 ------------
8
9 Install with pip3:
10
11 pip3 install pyfastaq
12
13
14 Alternatively, you can download the latest release from this github repository,
15 or clone the repository. Then run the tests:
16
17 python3 setup.py test
18
19 If the tests all pass, install:
20
21 python3 setup.py install
22
23
24 Usage
25 -----
26
27 The installation will put a single script called `fastaq` in your path.
28 The usage is:
29
30 fastaq <command> [options]
31
32
33 Key points:
34 * To list the available commands and brief descriptions, just run `fastaq`
35 * Use `fastaq command -h` or `fastaq command --help` to get a longer description and the usage of that command.
36 * The type of input file is automatically detected. Currently supported:
37 `FASTA`, `FASTQ`, `GFF3`, `EMBL`, `GBK`, `Phylip`.
38 * `fastaq` only manipulates sequences (and
39 quality scores if present), so annotation is ignored where present in the input.
40 * Input and output files can be gzipped. An input file is assumed to be gzipped if its name ends with .gz. To gzip an output file, just name it with .gz at the end.
41 * You can use a minus sign for a filename to use stdin or stdout, so commands can be piped together. See the example below.
42
43
44 Examples
45 --------
46
47 Reverse complement all sequences in a file:
48
49 fastaq reverse_complement in.fastq out.fastq
50
51 Reverse complement all sequences in a gzipped file, then translate each sequence:
52
53 fastaq reverse_complement in.fastq.gz - | fastaq translate - out.fasta
54
55
56 Available commands
57 ------------------
58
59 | Command | Description |
60 |-----------------------|----------------------------------------------------------------------|
61 | acgtn_only | Replace every non acgtnACGTN with an N |
62 | add_indels | Deletes or inserts bases at given position(s) |
63 | caf_to_fastq | Converts a CAF file to FASTQ format |
64 | capillary_to_pairs | Converts file of capillary reads to paired and unpaired files |
65 | chunker | Splits sequences into equal sized chunks |
66 | count_sequences | Counts the sequences in input file |
67 | deinterleave | Splits interleaved paired file into two separate files |
68 | enumerate_names | Renames sequences in a file, calling them 1,2,3... etc |
69 | expand_nucleotides | Makes every combination of degenerate nucleotides |
70 | fasta_to_fastq | Convert FASTA and .qual to FASTQ |
71 | filter | Filter sequences to get a subset of them |
72 | get_ids | Get the ID of each sequence |
73 | get_seq_flanking_gaps | Gets the sequences flanking gaps |
74 | interleave | Interleaves two files, output is alternating between fwd/rev reads |
75 | make_random_contigs | Make contigs of random sequence |
76 | merge | Converts multi sequence file to a single sequence |
77 | replace_bases | Replaces all occurrences of one letter with another |
78 | reverse_complement | Reverse complement all sequences |
79 | scaffolds_to_contigs | Creates a file of contigs from a file of scaffolds |
80 | search_for_seq | Find all exact matches to a string (and its reverse complement) |
81 | sequence_trim | Trim exact matches to a given string off the start of every sequence |
82 | sort_by_name | Sorts sequences in lexographical (name) order |
83 | sort_by_size | Sorts sequences in length order |
84 | split_by_base_count | Split multi sequence file into separate files |
85 | strip_illumina_suffix | Strips /1 or /2 off the end of every read name |
86 | to_fake_qual | Make fake quality scores file |
87 | to_fasta | Converts a variety of input formats to nicely formatted FASTA format |
88 | to_mira_xml | Create an xml file from a file of reads, for use with Mira assembler |
89 | to_orfs_gff | Writes a GFF file of open reading frames |
90 | to_perfect_reads | Make perfect paired reads from reference |
91 | to_random_subset | Make a random sample of sequences (and optionally mates as well) |
92 | to_tiling_bam | Make a BAM file of reads uniformly spread across the input reference |
93 | to_unique_by_id | Remove duplicate sequences, based on their names. Keep longest seqs |
94 | translate | Translate all sequences in input nucleotide sequences |
95 | trim_Ns_at_end | Trims all Ns at the start/end of all sequences |
96 | trim_contigs | Trims a set number of bases off the end of every contig |
97 | trim_ends | Trim fixed number of bases of start and/or end of every sequence |
98 | version | Print version number and exit |
99
100
101 For developers
102 --------------
103
104 Here is a template for counting the sequences in a FASTA or FASTQ file:
105
106 from pyfastaq import sequences
107 seq_reader = sequences.file_reader(infile)
108 count = 0
109 for seq in seq_reader:
110 count += 1
111 print(count)
112
113 Hopefully you get the idea and there are plenty of examples in tasks.py. Detection of the input file type and whether gzipped or not is automatic. See help(sequences) for the various methods already defined in the classes Fasta and Fastq.
114
115 ---------------------------------
116
117 Build status: [![Build Status](https://travis-ci.org/sanger-pathogens/Fastaq.svg?branch=master)](https://travis-ci.org/sanger-pathogens/Fastaq)
118
119