标签: append

将 FASTA 文件中的多个序列添加到 python 中的列表中

我正在尝试组织具有多个序列的文件。在此过程中,我尝试将名称添加到列表中,并将序列添加到与名称列表并行的单独列表中。我弄清楚了如何将名称添加到列表中,但我不知道如何将其后面的序列添加到单独的列表中。我尝试将序列行附加到空字符串中,但它将所有序列的所有行附加到单个字符串中。

所有名称均以“>”开头

def Name_Organizer(FASTA,output):

    import os
    import re

    in_file=open(FASTA,'r')
    dir,file=os.path.split(FASTA)
    temp = os.path.join(dir,output)
    out_file=open(temp,'w')

    data=''
    name_list=[]

    for line in in_file:

        line=line.strip()
        for i in line:
            if i=='>':
                name_list.append(line)
                break
            else:
                line=line.upper()
        if all([k==k.upper() for k in line]):
            data=data+line

    print data
Run Code Online (Sandbox Code Playgroud)

如何将序列作为一组字符串添加到列表中?

输入文件看起来像这样

在此输入图像描述

python list append sequence fasta

3
推荐指数
1
解决办法
8399
查看次数

D3.js:追加后获取parentNode

我想将循环中的元素附加到“root”-div,然后返回 DOM 树以附加另一个元素/设置文本(在 D3.js 中)。

所需的结构:

root > div > div 
           > text
     > div > div
           > text
     > ... 
Run Code Online (Sandbox Code Playgroud)

代码:

root > div > div 
           > text
     > div > div
           > text
     > ... 
Run Code Online (Sandbox Code Playgroud)

错误消息:

[...].parentNode is undefined
Run Code Online (Sandbox Code Playgroud)

D3 有没有办法在追加元素后沿着树向上移动?

dom structure append d3.js

3
推荐指数
1
解决办法
1947
查看次数

使用 printf 将零添加到整数值

我正在尝试使用该函数向用户输入的数字添加零printf()。但是,我不确定语法用法。这是我到目前为止所拥有的:

public class Solution {

    public static void main(String[] args) {
            Scanner reader = new Scanner(System.in);
            final int requiredNumLength = 3;
            // readign untill EOF
            while (reader.hasNext()){
                    // getting the word form the input as a string
                    String word = reader.next();
                    // getting the number from the input as an integer
                    int num = reader.nextInt();
                    int length = String.valueOf(num).length();
                            if (length < requiredNumLength){
                                    int zerosRequired = requiredNumLength - length;
                                    //System.out.println("required zeros: " + zerosRequired);
                            }
                    // print out …
Run Code Online (Sandbox Code Playgroud)

java printf append

3
推荐指数
1
解决办法
5734
查看次数

Python列表追加时更新元素

我有一个 python 列表,我想将一个列表附加到其中。该列表是这样声明的:

data = []
Run Code Online (Sandbox Code Playgroud)

然后我在列表中附加:

[0, 0, 0, 0, 0, 0, 0, 1, 0]
Run Code Online (Sandbox Code Playgroud)

之后我想附加另一个列表:

[0, 0, 0, 0, 0, -1, 0, 1, 0]
Run Code Online (Sandbox Code Playgroud)

然后,当我打印出整个列表时,它显示:

[[0, 0, 0, 0, 0, -1, 0, 1, 0], [0, 0, 0, 0, 0, -1, 0, 1, 0]]
Run Code Online (Sandbox Code Playgroud)

当我尝试将其打印出来时:

[[0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, -1, 0, 1, 0]]
Run Code Online (Sandbox Code Playgroud)

当我像这样附加它时,它更新了数组的第一个元素:

data.append(prev_board)
Run Code Online (Sandbox Code Playgroud)

prev_board 存储要附加到列表的列表。我的整个代码是:

def gather_training_data(games):
global data
global game_won

for each_game in range(games):
    game = …
Run Code Online (Sandbox Code Playgroud)

python pygame updating list append

3
推荐指数
1
解决办法
3874
查看次数

如何在 numpy 数组中获取用户输入

import numpy

my_array = numpy.array([])
a=int(input("Size of array:"))
for i in range(a):
    x=float(input("Element:"))
    numpy.append(x)

print(numpy.floor(my_array))
Run Code Online (Sandbox Code Playgroud)

python arrays numpy input append

3
推荐指数
1
解决办法
6万
查看次数

加载 DOM 后在附加上执行 &lt;script&gt; 标记

我正在尝试在模式中观看 onClick 视频,而无需访问视频页面本身。

我正在使用 Vue.js,通过一系列 Ajax 调用,我能够完成大部分工作。

Codpen: https: //codepen.io/nolaandy/pen/BrbBzO

如果您点击顶部的“对阵太阳队”,您会看到所有视频帖子的列表。然后单击任何图像,模式组件会弹出并动态获取帖子的标题。

我也想在那里运行视频,所以我尝试运行这个脚本标签:

 < script class="_nbaVideoPlayerScout" data-team="warriors" data-videoId="/video/{{unique videoId from post ajax call}}" data-width="768" data-height="732" src="https://www.nba.com/scout/team/cvp/videoPlayerScout.js"></script>
Run Code Online (Sandbox Code Playgroud)

当模式弹出时,我看到我单击的帖子/图像的正确标题,并且我看到脚本标签与检查器中应有的完全相同,但脚本标签从未运行。

我应该有什么不同的方式来注入这个脚本吗?(这是在 axios 响应调用内部)

let theVideoId = response.data.content[0].videoID


let s = document.createElement('script')
s.setAttribute('class', '_nbaVideoPlayerScout')
s.setAttribute('data-team', 'warriors') 
s.setAttribute('data-videoId', '/video/' + theVideoId) 
s.setAttribute('data-width', '768') 
s.setAttribute('data-height', '732') 
s.setAttribute('src', 'https://www.nba.com/scout/team/cvp/videoPlayerScout.js')
document.getElementById('popupVideo').appendChild(s);
Run Code Online (Sandbox Code Playgroud)

模态组件——点击帖子缩略图之一时触发

const videoModal = Vue.component('VideoModal', {
props: {
    id: {
    type: String,
    required: true
    }
},
data: function () {
  return {
    post: [],
  }
},
mounted() { …
Run Code Online (Sandbox Code Playgroud)

javascript append vue.js

3
推荐指数
1
解决办法
3115
查看次数

如何在 Vue.js 中动态地将 HTML 元素附加到组件

我是 vue.js 的新手,在此之前我在我的项目中使用 jquery 或 js,我正在开发一个项目,该项目要求我在按钮单击时动态附加 HTML 元素,同时绑定输入值建模,类似于:

$(".button").click(function() {
 $("#target").append("<input type='hidden' name='data' v-model='inputModel' value='1'/>");
});
Run Code Online (Sandbox Code Playgroud)

但我需要 Vue.js 的方式。

这是我的代码:

data() {
    return {
      programmeBanner: [],
      dropzoneOptions: {
        ...
        ...
        init: function () {
          this.on("success", function(file, response) {
            file.previewElement.id = response;

            // this is the part that i want to append the html input into
            // the .dz-preview is the target that i want to append 
            $(".dz-preview[id='"+response+"']").append("<input type='hidden' name='"+fileInputName+"[]' v-model='programmeBanner' class='"+fileInputName+"' value='"+response+"'/>");
          });
        },
        ...
Run Code Online (Sandbox Code Playgroud)

这是我想要实现的示例,这是在 Jquery 中,我在 Vue.js 中需要它 …

html append vue.js

3
推荐指数
1
解决办法
1万
查看次数

如何以递归方式更改字符串向字符串添加一个数字并将每个数字添加到列表中

我正在做一个项目,我必须更改一个字符串并将其添加到列表中。

像这样的东西:

def function(string, amount), do: "string + amount" end

其中数量增加直到 n。

下一步是将此字符串添加到列表中,因此我将收到:

[string1, string2,...., string]
Run Code Online (Sandbox Code Playgroud)

如何使用 Elixir 将此字符串递归地附加到基于增加的数量的列表中?

recursion append elixir

3
推荐指数
1
解决办法
79
查看次数

使用仅对角线数据的表中的值创建一行

我在熊猫中有下表-

>>>index1   index2   index3   index4   index5   index6   index7
0   sig      null    null     null     null     null     null
1   null      sig     null     null     null     null     null
2   null      null    sig      null     null     null     null
3   null      null    null     sig      null     null     null
4   null      null    null     null     no sig   null     null
5   null      null    null     null     null     no sig   null
6   null      null    null     null     null     null     sig
Run Code Online (Sandbox Code Playgroud)

我想摆脱减少空值并将数据放在一行中,如下所示:

>>>index1   index2   index3   index4   index5   index6   index7
0   sig      sig     sig      sig      no …
Run Code Online (Sandbox Code Playgroud)

python null if-statement append pandas

3
推荐指数
1
解决办法
84
查看次数

计算列表元组中每个列表中给定单词的出现次数

我有一个标记化句子列表,我想计算几个单词的集体出现次数:例如:

example_list = (['hey', 'there', 'you', 'how', 'are', 'you'],
                ['i', 'am', 'fine', 'how', 'about', you],
                ['i', 'am', 'good'])
Run Code Online (Sandbox Code Playgroud)

现在我想计算每个列表中以下单词出现的次数并将分数附加到列表中

score = []
test = ['hey', 'you']
Run Code Online (Sandbox Code Playgroud)

我尝试以下代码:

for i in range(len(test)):
   for j in range(len(example_list)):
       score1.append(example_list[j].count(test[i]))
Run Code Online (Sandbox Code Playgroud)

并获得以下输出:

[1, 0, 0, 2, 1, 0]
Run Code Online (Sandbox Code Playgroud)

而我想要输出:

[3, 1, 0]
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

python list append count

3
推荐指数
1
解决办法
158
查看次数