C++
- voluntas
- @ignis_fatuus
- ブン
- @Linda_pp
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- I (@wx257osn2)
- Tommy6
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
46
1
2
3
4
5
int main(void) {
6
std::string command_string;
7
std::string str_row;
8
std::string chr_colon;
9
std::string period = ".";
10
/*
11
Here are the current values of file_name, chr, lookup_locus, and row, though these objects are actually defined as part of a for-loop as it reads through a "lookup table" with chromosomes and loci and a "sam file" designated by "file_name"
12
*/
13
std::string file_name = "Polly_SRR6511974.bam";
14
std::string chr = "ScyDAA6_1_HRSCAF_23";
15
int row = 0;
16
std::string lookup_locus = "67748";
17
/*
18
Create a string telling the system what to do with the bam file. Intention is to construct a string saying
19
"samtools view SRR6511974.bam -o lookup0_Polly_SRR6511974.sam ScyDAA6_1_HRSCAF_23:67748-67748 Polly_SRR6511974.bam"
20
*/
21
command_string = "samtools view ";
22
command_string.append(file_name);
23
command_string.append(" -o lookup");
24
str_row = std::__cxx11::to_string(row);
25
command_string.append(str_row);
26
// You want to add row1 to the string to differentiate between files generated from other LOOKUP rows
27
command_string.append("_");
28
/*
29
The file name has both accession number and ".bam" designation. You want the output to be in sam format, so just enter the accession number then a ".sam" string.
30
*/
31
command_string.append(file_name.substr(0, file_name.find(period)));
32
command_string.append(".sam ");
33
chr_colon = chr.append(":");
34
command_string.append(chr_colon);
35
command_string.append(lookup_locus);
36
command_string.append("-");
37
command_string.append(lookup_locus);
38
39
40
std::cout << "Outputting the following command to the console:\n" << command_string << "\n\n";
41
// Convert command string to const char* type so it can be outputted to console
42
const char * char_command = command_string.c_str();
43
// From each sample file, extract the reads within 100bp of the current row in the lookup table.
44
system(char_command);
45
}
46
$ g++ prog.cc -Wall -Wextra -std=gnu++2a
Start
sh: 1: samtools: not found
Outputting the following command to the console: samtools view Polly_SRR6511974.bam -o lookup0_Polly_SRR6511974.sam ScyDAA6_1_HRSCAF_23:67748-67748
0
Finish