Skip to content

tutorial 8 part 1#7

Open
amidlige wants to merge 1 commit into
lyy005:masterfrom
amidlige:master
Open

tutorial 8 part 1#7
amidlige wants to merge 1 commit into
lyy005:masterfrom
amidlige:master

Conversation

@amidlige

Copy link
Copy Markdown

No description provided.

Comment thread exercise8.py
var3=re.match([0-9],[0-9],line)
outfile.write(var3)


@lyy005 lyy005 Nov 2, 2017

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for line in vcffile:
line = line.strip()
# if the line starts with "##", skip
if line[0:1] == "##":
outfile.write(line + "\n")
#if the line starts with "#", replace names with fixed names
elif line[0] == "#":
# apply all substitutions
names = re.sub("[Cc]Ff?.[Aa]2?","Cf.Sfa",line)
names = re.sub("[Cc][Ff].(G2|GAI|gai)","Cf.Gai",names)
# write line
outfile.write(names + "\n")
else:
#grab allele
sub = re.sub("[01.]/[01.]:([0-9,.]+):[0-9.]+:[0-9.]+:[0-9,.]+",r"\1",line)
#if allele counts . replace with NA
sub = re.sub(".","NA",sub)
#write line to new file
outfile.write(sub + "\n")

-0.5 points

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants