match

Match specific pattern and print just the matched string in the previous line: Updated

若如初见. 提交于 2020-01-25 08:48:05
问题 I have a .fastq file formatted in the following way @M01790:39:000000000-C3C6P:1:1101:14141:1618 1:N:0:8 (name) AACATCTACATATTCACATATAGACATGAAACACCTGTGGTTCTTCCTCAGTATGTAGGACTGTAACATAG (sequence) + GGACCCGGGGGGGGGDGGGFGGGGGGFGGGGGGGGGGGFGGGGFGFGFFFGGGGGGFGGGGGGGGGGGFGG (quality) For each sequence the format is the same (repetition of 4 lines) What I am trying to do is searching for specific regex pattern in a window of n=35 characters of the 2nd line, cut it if found and report it at the end

Multiple Criteria Match/Index VBA Across two sheets

点点圈 提交于 2020-01-25 07:53:05
问题 Multi Criteria Index/Match VBA across two sheets in the same workbook So, basically, I have 2 sheets in a same workbook Sheet 1 looks like this: Sheet 2 looks like this: I want to match the Comments section based on PO/SO AND Activity using VBA instead of formula. Below is the code I tried to write, but it’s not working… Dim ID As String, Activity As String For r = 2 To ThisWorkbook.Worksheets("Sheet1").UsedRange.Rows.Count ID = ThisWorkbook.Worksheets("Sheet1").Cells(r, 1).Value Activity =

Array to lookup multiple columns and take another columns information

南笙酒味 提交于 2020-01-25 07:25:55
问题 I am trying to lookup a part number in a separate table array, the same value could be in multiple rows. The formula should find each instance of the value in the other table, move to a date column and determine which months the value exists in and which row it belongs to. The entire table B3:F15 should be automated. I have attached an image with proper explanation of what I am trying to accomplish if at all possible. The formulas would be entered into B3:F15. These are the cells where the

Keep all elements in one list from another

谁都会走 提交于 2020-01-25 04:18:22
问题 I have two large lists train and keep , with the latter containing unique elements, for e.g. train = [1, 2, 3, 4, 5, 5, 5, 5, 3, 2, 1] keep = [1, 3, 4] Is there a way to create a new list that has all the elements of train that are in keep using sets ? The end result should be: train_keep = [1, 3, 4, 3, 1] Currently I'm using itertools.filterfalse from how to keep elements of a list based on another list but it is very slow as the lists are large... 回答1: Convert the list keep into a set ,

Keep all elements in one list from another

隐身守侯 提交于 2020-01-25 04:17:05
问题 I have two large lists train and keep , with the latter containing unique elements, for e.g. train = [1, 2, 3, 4, 5, 5, 5, 5, 3, 2, 1] keep = [1, 3, 4] Is there a way to create a new list that has all the elements of train that are in keep using sets ? The end result should be: train_keep = [1, 3, 4, 3, 1] Currently I'm using itertools.filterfalse from how to keep elements of a list based on another list but it is very slow as the lists are large... 回答1: Convert the list keep into a set ,

R select rows in matrix from another vector (match, %in)

拈花ヽ惹草 提交于 2020-01-25 01:57:12
问题 Say I have a dataframe with 6 columns and 100000 rows. I want to select rows in matrix originScen based on the indices/numbers in another vector reducedScenIds (10,000 rows). I select the rows by checking if the value of each member of Y matches the value in column 1 of the dataframe X. Now the first column can have multiple matches for each value of Y. So I used the below reducedSet <- originScen[which(originScen[,1] %in% reducedScenarioIds),] I am ok with the results except that which and

Python 正则表达式

限于喜欢 提交于 2020-01-24 15:32:33
Python 正则表达式 在Python中需要通过正则表达式对字符串进行匹配的时候,可以使用一个模块来操作,名字为re import re (1)三种基本方法 在re模块中,通常使用三种方法,match,search和findall,下面对这三种方法进行简单的介绍: 一.match方法 re.match 尝试从字符串的 起始位置 匹配一个模式,匹配成功则返回的是一个匹配对象(这个对象包含了我们匹配的信息),如果不是起始位置匹配成功的话,match()返回的是空, 注意:match只能匹配到一个 ** 下面来看代码理解 s = 'python123python666python888' result = re . match ( 'python' , s ) print ( result ) # <re.Match object; span=(0, 6), match='python'> print ( result . span ( ) ) # (0, 6) print ( result . group ( ) ) # python 1.通过span()提取匹配到的字符下标 2.通过group()提取匹配到的内容 而s字符串中有3个python的存在,match只能匹配到一个 下面我们改变一下s,得到不一样的结果 s = '1python123python666python888'

Return value based on finding closest value between other two columns in df

房东的猫 提交于 2020-01-24 12:24:57
问题 My question is almost identical to this one except instead of finding the closest value between a column value and a fixed number, e.g. "2", I want to find the closest value to the value in another column. . Here's an example of data: df <- data.frame(site_no=c("01010500", "01010500", "01010500","02010500", "02010500", "02010500", "03010500", "03010500", "03010500"), OBS=c(423.9969, 423.9969, 423.9969, 123, 123, 123, 150,150,150), MOD=c(380,400,360,150,155,135,170,180,140), HT=c(14,12,15,3,8

Regex to accept 3 out of 4 rules

狂风中的少年 提交于 2020-01-24 09:54:12
问题 I can't seem to get the regex correct for the following requirement: a string between 8 and 20 length that must contain at least 1 uppercase alphabet character, at least 1 lowercase alphabet character, and either at least 1 digit or at least 1 special character (or both). Let's say special characters are restricted to include just @,#,&,~. I wrote this initially: ^(?=.*?[A-Z])(?=.*?[a-z])(?=(.*?[0-9])|(.*?[@#&~])).{8,20}$ So as expected it successfully matches strings like 5abcdefG, Abc

Extract id with matching pattern on several rows in dataframe

夙愿已清 提交于 2020-01-24 09:39:06
问题 Here is an example of a dataframe I'm working on : id string 1 no 1 yes 1 yes 2 no 2 yes 3 yes 3 yes 3 no I want to extract the id for which the last two rows contain the string "yes" for the column string . So the results would be : id string 1 yes 1 yes And I would have only one id which will be 1 . I tried to do this with a for loop but since I have more than 200 000 lines, the loop is taking too much time : more than 5 minutes . I tried this : vec_id <- unique(df$id) for(id in vec_id){ if