Skip to content

burton_doherty_submission#8

Open
timaburton wants to merge 2 commits into
lyy005:masterfrom
timaburton:master
Open

burton_doherty_submission#8
timaburton wants to merge 2 commits into
lyy005:masterfrom
timaburton:master

Conversation

@timaburton

Copy link
Copy Markdown

No description provided.

Comment thread Exercise08_1.py
for line in vcffile:#look at old code to see how you looped over a file
#strip end of line
line=line.strip()
if lineNumber==0: #how can you tell if this is the header line?

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.

Or you can use
if line[0:1] == "##":

Comment thread Exercise08_1.py
elif lineNumber==1: #how can you tell if this is the line with the column headings?
#standardize (replace) sample names with TX and FL regexes
re.sub(((CF|cf){1}.?{4}\.,(Cf.Sfa.),line) ###Having trouble gettig re.sub to work, syntax not working. Trying to replace CF and then any 4 characters leading to a period
re.sub(((CF|cf){1}.?{4}\.,(Cf.Gai.),line)

@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.

Quotation mark is missing.
names = re.sub("[Cc]Ff?.[Aa]2?","Cf.Sfa",line)
names = re.sub("[Cc][Ff].(G2|GAI|gai)","Cf.Gai",names)

Comment thread Exercise08_1.py
#write new version of line to file
outfile.write(line+"\n")
else: #now you're in the data
#replace full SNP info with allele counts only

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.

sub = re.sub("[01.]/[01.]:([0-9,.]+):[0-9.]+:[0-9.]+:[0-9,.]+",r"\1",line) # extract allele information
sub = re.sub(".","NA",sub) #if allele counts . replace with NA

Comment thread Exercise08_1.py
#write new version of line to new file

#Close files

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.

-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.

3 participants