- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 swig 来包装这个 C++ 项目,并且在将所有头文件导入我的 python 代码之后,我现在正致力于在 python 中重新创建主类,但是我在寻找对应的数据结构和数据类型。下面是main.cpp下的main方法
int main( int argc, char *argv[] )
{
string exe_name = argv[ 0 ];
string usage = "Usage: " + exe_name + " unigene.fasta [options]\n\
Options:\n\
-g <GC content> \tminimum GC content in percentage (Default 45).\n\
-G <GC content> \tmaximum GC content in percentage (Default 55).\n\
-m <temperature> \tlowest melting temperature in degrees of celsius (Default 0).\n\
-M <temperature> \thighest melting temperature in degrees of celsius (Default 100).\n\
-r <repeat.fasta> \tfasta file containing repeat DNA sequences.\n\
-t <top number> \tnumber of top oligos selected for each unigene (Default 1).\n\n";
string unigene_file;
// options only, each must have an associated value
int min_gc = 45;
int max_gc = 55;
int min_tm = 0;
int max_tm = 100;
int top_num = 1;
string repeat_file;
vector< string > m_argument;
for ( int i = 0; i < argc; i ++ ) {
string new_arg = argv[ i ];
m_argument.push_back( new_arg );
}
parse_argument( m_argument, usage, unigene_file,
min_gc, max_gc, min_tm, max_tm, top_num, repeat_file );
// initialize filtration parameters
float norm_min_gc = (float)min_gc / 100.0;
float norm_max_gc = (float)max_gc / 100.0;
string splice_file; // empty splice file
filt_param m_filtparam( norm_min_gc, norm_max_gc, min_tm, max_tm,
repeat_file, splice_file );
// screen unigenes for unique oligos
seqs m_unigene;
m_unigene.init( unigene_file );
// map from unigene names to oligo sequences
map< string, vector< string > > uniq_oligo;
get_unique_oligo( m_unigene, m_filtparam, top_num, uniq_oligo );
// output oligos
if ( uniq_oligo.empty() ) {
cout << "No valid oligo has been found. " << endl <<
"It could be due to one of the following reasons: " << endl <<
"1. input sequences are not unique, or " << endl <<
"2. they are repetitive DNAs, or " << endl <<
"3. GC% range is too restricted, etc. " << endl;
}
map< string, vector< string > > :: const_iterator m_itr;
for ( m_itr = uniq_oligo.begin(); m_itr != uniq_oligo.end(); m_itr ++ ) {
for ( int o_idx = 0; o_idx < (int)m_itr->second.size(); o_idx ++ ) {
cout << ">unique-oligo-" << o_idx+1 << "-of-unigene-" <<
m_itr->first << endl;
cout << m_itr->second[ o_idx ] << endl;
}
}
//system("PAUSE");
return 1;
}
例如,当我尝试将一个空字符串 (repeat_file) 传递给 filtparam() 时,在 python 中,我得到了错误
in method 'new_filt_param', argument 5 of type 'string const &'
如何在 python 中声明一个“string const &”类型?
还有python中有'map'这样的结构吗?
最佳答案
您正在寻找的是 dict
,它的工作原理与 C++ 的 map
基本相似。更多信息可以在 documentation 中找到.
不同的问题:您是否有任何理由在 Python 中重新创建 main()
而不是简单地用 SWIG 包装那个?虽然 SWIG 能够以有限的方式处理 std::string
之类的事情,但我会尝试使用仅使用指针/数组的更简单的接口(interface),而不是尝试传递任何 C++ 对象或构造.
关于c++ - 将 C++ 代码移植到 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12723491/
我是 Mercurial 的新手,并且不知何故仍处于评估过程中,所以这四个概念对我来说有点困惑。有些被提到等同于 Git 的 Staging/Index 概念,有些甚至比 Git 的 Staging
如何将在某些网站 (www.example1.com) 上用某种语言即 (java) 制作的 session 传送到用其他语言制作的网站,即在某些其他网站上的 (php),即 (www.example
我有以下代码行我想移植到 Torch Matmul rotMat = xmat @ ymat @ zmat 我能知道这是不是正确的顺序: rotMat = torch.matmul(xmat, tor
我正在尝试移植一个内部有一个联合的 C 结构。 Winapi.Winsock2.pas 中的默认结构记录中缺少某些字段。 但这是正确的方法吗?谢谢。 typedef struct _WSACOMPLE
我想将基于 webkit 的浏览器移植到我的堆栈中。谁能介绍一下 webkit 浏览器引擎的组织结构?目前我所知道的是它具有用于呈现 html 和解析 javascript 的核心。我想了解更多,比如
我目前有一个 ActiveX 控件,它链接到许多 c/c++ dll。问题是我们现在需要此控件在 IE 以外的浏览器(最重要的是 Firefox)上运行。 在我看来,我有以下选择: 将控件编写为 fi
我正在尝试在 Objective-C 中重写 Java 库。我想将其重写为 API,以便需要实现某些方法。我已经开始尝试重写代码,但遇到了一些问题。 Objective-C 是否支持抽象类? 如果没有
我已经有一段时间没有接触 SQL 了,所以我需要重新学习一下。我的计算机上运行着一个 SQL 数据库,我的服务器是 localhost。我在 VB.Net 中制作了一个连接到该数据库的应用程序。一切都
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit th
运行命令时出现错误 [root@himanshi busybox-1.20.2]# make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnueabi- CON
我需要将为 iPhone 编写的现有游戏移植到 Flash。 iPhone 游戏主要是用纯 C 而不是 Objective C 编写的。 我想知道是否有任何好的工具可以将 C 代码直接转换为 Acti
我将要在 Smalltalk (Pharo) 中构建一个项目。还有一个 python 库,我打算将其用于相同的目的。现在,有 3 个选项: 那些 python 库的 Smalltalk 包装器 将 p
我必须在 GPU 上移植一个广泛使用随机数的结构。一切都可以毫无问题地移植,但随机生成器函数是唯一在该类的所有函数中被广泛调用的函数。我虽然可以简单地将它重新实现为类本身的内部设备函数。下面我放了一个
我对整个移植问题有点陌生,因为 Android SDK 提供的模拟器速度很慢,所以我解决了这个问题。 我下载了 android-x86-3.2-RC2-eeepc 和 android-x86-3.2-
我们的数据库 (PostgreSQL 9.x) 中有一些 PL/pgSQL 存储过程。 这些是严格顺序的,在某些情况下,可能会非常慢。 我们正在考虑将它们移植到 PL/Java、PL/Python 或
我有一个 Android 应用程序可以处理圆顶图像。出于性能原因,我想用 C++ 编写应用程序的某些部分,然后通过 NDK 调用这些方法。我是否需要一个特定的 C++ 编译器(例如用于嵌入式系统)或者
我正在从事一个将一大堆 OS-9(微软件)代码移植到 linux 的项目。 OS-9 中的信号处理功能允许您创建自己的信号,或者至少它是如何实现的(intercept() 函数)。我对 linux 信
目前我有这个 gtk2 代码: GList *input_devices = gdk_devices_list(); while(input_devices) { GdkDevice *devic
我正在尝试移植 Aether.Physics2D从 C# 到 Xojo 的库。这本质上是 Farseer 物理引擎的调整版本。大部分已经完成,但有一部分源代码我无法解决(可能是因为 C# 不是我的主要
我们正在开发采用 RISCV 架构的多核处理器。 我们已经为单核 RISCV 处理器移植了 Linux,它正在我们自己的基于 FPGA 的主板上使用 busybox rootfs。 我现在想为多核 R
我是一名优秀的程序员,十分优秀!